note 51720 deleted from function.fread by cmb
| From: | cmb@php.net | Date: | Sun, 12 Jan 2020 08:18:10 +0000 |
| Subject: | note 51720 deleted from function.fread by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213845@lists.php.net to get a copy of this message | ||
Note Submitter: planetiss at gmail dot com
----
For download the big files (more than 8MB), you must used ob_flush() because the function flush
empty the Apache memory and not PHP memory.
And the max size of PHP memory is 8MB, but ob_flush is able to empty the PHP memory.
<?php
header('Content-Type: application/force-download');
header ("Content-Length: " . filesize($file));
header ("Content-Disposition: attachment; filename=$theFileName");
$fd = fopen($file, "r");
while(!feof($fd))
{
echo fread($fd, 4096);
ob_flush();
}
?>