Saturday, June 28, 2014

Re: CakePHP download function returns 'empty' file

<pre class="cake-error">
$file = object(File) {
Folder =&gt; object(Folder) {}
name =&gt; &#039;200323860053ad7ddaaaddd.png&#039;
info =&gt; array(
&#039;dirname&#039; =&gt; &#039;/var/www/upfree/up-free.com/files/posts/attach&#039;,
&#039;basename&#039; =&gt; &#039;200323860053ad7ddaaaddd.png&#039;,
&#039;extension&#039; =&gt; &#039;png&#039;,
&#039;filename&#039; =&gt; &#039;200323860053ad7ddaaaddd&#039;,
&#039;filesize&#039; =&gt; (int) 10026,
&#039;mime&#039; =&gt; &#039;image/png&#039;
)
handle =&gt; resource
lock =&gt; null
path =&gt; &#039;/var/www/upfree/up-free.com/files/posts/attach/200323860053ad7ddaaaddd.png&#039;
}
$range = null
$compress = false
$end = false
$start = false
$bufferSize = (int) 8192</pre><pre class="stack-trace">set_time_limit - [internal], line ??
CakeResponse::_sendFile() - CORE/Cake/Network/CakeResponse.php, line 1375
CakeResponse::send() - CORE/Cake/Network/CakeResponse.php, line 425
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 169
require - APP/webroot/index.php, line 97
[main] - ROOT/index.php, line 13</pre></div></pre>‰PNG

пятница, 27 июня 2014 г., 1:24:55 UTC+3 пользователь AD7six написал:


On Friday, 20 June 2014 20:05:55 UTC+2, Alexandr Pirogov wrote:
Help me, please, to resolve my small problem! I have next function in my PostsController:

public function download() {      if (isset($this->request->query['file']) && is_file(POST_ATTACH_PATH . $this->request->query['file'])) {          $file = $this->request->query['file'];          $output_name = 'up_free_' . rand();            $this->response->file(POST_ATTACH_PATH . $file, array(              'download' => true, 'name' => $output_name          ));            return $this->response;      } else {          $this->redirect(array('controller' => 'posts', 'action' => 'index'));      }  }

The problem is that my download function returns me 'empty' file! For example, if I have attached an image to the post and click the download button, my image downloads! But downloaded file is 'empty', I can't open it and if it is .jpg file it has the size of 132 KB.

Thank You!


132KB is not empty - try opening it as a text file - it probably contains error messages.

AD 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: