note 32066 added to function.fpassthru
| From: | arabold at rack1 dot php dot net | Date: | Thu, 15 May 2003 09:11:26 +0000 |
| Subject: | note 32066 added to function.fpassthru | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-48012@lists.php.net to get a copy of this message | ||
Here's a summary the different headers you need to set to make downloads *always* work with IE
and Mozilla:
[SNIP]
$disposition = "inline"; // "inline" to view file in browser or
"attachment" to download to hard disk
$mime = "image/jpeg"; // or whatever the mime type is
$name = "foo.jpg"; // file name
$path = "/path/to/foo.jpg"; // full path and file name
if (isset($_SERVER["HTTPS"])) {
/**
* We need to set the following headers to make downloads work using IE in HTTPS mode.
*/
header("Pragma: ");
header("Cache-Control: ");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
}
else if ($disposition == "attachment") {
header("Cache-control: private");
}
else {
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
}
header("Content-Type: $mime");
header("Content-Disposition:$disposition;
filename=\"".trim(htmlentities($name))."\"");
header("Content-Description: ".trim(htmlentities($name)));
header("Content-Length: ".(string)(filesize($path)));
header("Connection: close");
[/SNIP]
This way all kinds of download work for me. Hope that helps
--
http://www.php.net/manual/en/function.fpassthru.php
http://master.php.net/manage/user-notes.php?action=edit+32066
http://master.php.net/manage/user-notes.php?action=delete+32066
http://master.php.net/manage/user-notes.php?action=reject+32066