Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm using the <code>readfile_chunked()</code> custom method as stated in php.net <a href="http://www.php.net/manual/en/function.readfile.php#54295" rel="nofollow">here</a>. For Laravel 3, I've extended the response method like this:</p> <p>Add this file as <code>applications/libraries/response.php</code></p> <pre><code>&lt;?php class Response extends Laravel\Response { //http://www.php.net/manual/en/function.readfile.php#54295 public static function readfile_chunked($filename,$retbytes=true) { $chunksize = 1*(1024*1024); // how many bytes per chunk $buffer = ''; $cnt =0; // $handle = fopen($filename, 'rb'); $handle = fopen($filename, 'rb'); if ($handle === false) { return false; } while (!feof($handle)) { $buffer = fread($handle, $chunksize); echo $buffer; ob_flush(); flush(); if ($retbytes) { $cnt += strlen($buffer); } } $status = fclose($handle); if ($retbytes &amp;&amp; $status) { return $cnt; // return num. bytes delivered like readfile() does. } return $status; } } </code></pre> <p>Then comment out this line in application/config/application.php:</p> <pre><code>'Response' =&gt; 'Laravel\\Response', </code></pre> <p>Example code:</p> <pre><code>//return Response::download(Config::get('myconfig.files_folder').$file-&gt;upload, $file-&gt;title); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.$file-&gt;title); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . File::size(Config::get('myconfig.files_folder').$file-&gt;upload)); ob_clean(); flush(); Response::readfile_chunked(Config::get('myconfig.files_folder').$file-&gt;upload); exit; </code></pre> <p>Works great so far.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload