note 81209 added to function.readfile
| From: | mail at 3v1n0 dot net | Date: | Mon, 18 Feb 2008 20:46:59 +0000 |
| Subject: | note 81209 added to function.readfile | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136250@lists.php.net to get a copy of this message | ||
I've problems using readfile with zip files in some browsers (like firefox)...
Also if I set the right file-size on headers my browser download only a part of file:
My code:
<?
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-type: '.file_type($file_path));
header('Content-Description: File Transfer');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.$size);
header('Content-Range: bytes 0-'.($size-1).'/'.$size);
header('Content-Disposition: attachment; filename="'.$file.'"');
exit(readfile($file_path));
?>
If I download a .zip file using wget (or konqueror) I get the right file with right size in my local
hard-drive, while using firefox I get only a partial (corrput) file:
-rw-r--r-- 1 user user 596671 2008-02-18 19:07 firefox-downloaded-file.zip
-rw-r--r-- 1 user user 596830 2008-02-18 19:08 wget-downloaded-file.zip
The strange thing is that looking at the headers output by the script, they states the right content
length: 596830.
Any idea to fix? Is this a firefox or php problem?
I've the same problem both on a php5 and php4 based servers.
----
Server IP: 59.162.86.33
Probable Submitter: 79.9.126.195
----
Manual Page -- http://www.php.net/manual/en/function.readfile.php
Edit -- https://master.php.net/note/edit/81209
Del: integrated -- https://master.php.net/note/delete/81209/integrated
Del: useless -- https://master.php.net/note/delete/81209/useless
Del: bad code -- https://master.php.net/note/delete/81209/bad+code
Del: spam -- https://master.php.net/note/delete/81209/spam
Del: non-english -- https://master.php.net/note/delete/81209/non-english
Del: in docs -- https://master.php.net/note/delete/81209/in+docs
Del: other reasons-- https://master.php.net/note/delete/81209
Reject -- https://master.php.net/note/reject/81209
Search -- https://master.php.net/manage/user-notes.php