note 51720 modified in function.fread by danbrown
| From: | danbrown@php.net | Date: | Fri, 06 Jan 2012 21:10:57 +0000 |
| Subject: | note 51720 modified in function.fread by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185438@lists.php.net to get a copy of this message | ||
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();
}
?>
--was--
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.
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();
}
http://php.net/manual/en/function.fread.php