note 34320 deleted from function.header by alindeman
| From: | alindeman@php.net | Date: | Wed, 23 Jul 2003 20:57:46 +0000 |
| Subject: | note 34320 deleted from function.header by alindeman | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-52521@lists.php.net to get a copy of this message | ||
Note Submitter:
----
Trying to use readfile() along with the header() for downloading the file. It work fine for
downloading. But with opening the file while downloading for IE, it blow up. So, instead of using
the readfile(), use fopen, fread, fclose instead and this fix the problem for IE.
--snip--
$file="test.exe";
header ("Pragma: public");
header ("Expires: 0"); // set expiration time
header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header ("Content-Type: application/force-download");
header ("Content-Type: application/octet-stream");
header ("Content-Type: application/download");
header ("Content-Disposition: attachment; filename=test_different_name.exe;");
header ("Content-Length: ".filesize($file));
header ("Content-Transfer-Encoding: binary");
//readfile($file);
//$content = fread ($fp, filesize($file));
//fclose ($fp);
//print $content;
$fp = fopen($file, 'rb');
$content = fread ($fp, filesize($file));
fclose ($fp);
print $content;
exit();
--snip--