note 86554 added to function.header
| From: | mzheng | Date: | Thu, 23 Oct 2008 15:50:58 +0000 |
| Subject: | note 86554 added to function.header | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-145649@lists.php.net to get a copy of this message | ||
For large files (100+ MBs), I found that it is essential to flush the file content ASAP, otherwise
the download dialog doesn't show until a long time or never.
<?php
header("Content-Disposition: attachment; filename=" . urlencode($file));
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Description: File Transfer");
header("Content-Length: " . filesize($file));
flush(); // this doesn't really matter.
$fp = fopen($file, "r");
while (!feof($fp))
{
echo fread($fp, 65536);
flush(); // this is essential for large downloads
}
fclose($fp);
?>
----
Server IP: 209.41.74.194
Probable Submitter: 205.247.136.10
----
Manual Page -- http://www.php.net/manual/en/function.header.php
Edit -- https://master.php.net/note/edit/86554
Del: integrated -- https://master.php.net/note/delete/86554/integrated
Del: useless -- https://master.php.net/note/delete/86554/useless
Del: bad code -- https://master.php.net/note/delete/86554/bad+code
Del: spam -- https://master.php.net/note/delete/86554/spam
Del: non-english -- https://master.php.net/note/delete/86554/non-english
Del: in docs -- https://master.php.net/note/delete/86554/in+docs
Del: other reasons-- https://master.php.net/note/delete/86554
Reject -- https://master.php.net/note/reject/86554
Search -- https://master.php.net/manage/user-notes.php