note 81209 rejected from function.readfile by nlopess
| From: | nlopess@php.net | Date: | Mon, 18 Feb 2008 22:45:51 +0000 |
| Subject: | note 81209 rejected from function.readfile by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-136255@lists.php.net to get a copy of this message | ||
Note Submitter: mail at 3v1n0 dot net
----
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.