note 51606 added to function.header
| From: | james at charity dot org | Date: | Tue, 05 Apr 2005 16:15:47 +0000 |
| Subject: | note 51606 added to function.header | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87509@lists.php.net to get a copy of this message | ||
If you're creating a download page for Internet Explorer, the following code works:
if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/MSIE/",
$_SERVER['HTTP_USER_AGENT'])) {
// IE Bug in download name workaround
ini_set( 'zlib.output_compression','Off' );
}
header('Content-type: ' . $file['type']);
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-Disposition: attachment; filename="' . $file['filename'] .
'"');
print($file['data']);
I will note that setting content length or size headers will cause IE to see the file being
opened/saved as 0 bytes and will on occasion open the content of the file in the browser itself
after the download fails.
I also recieved file not found problems until I added the Pragma and Cache-Control headers.
Yet another one of those "Thanks Bill" situations.
--james
----
Manual Page -- http://www.php.net/manual/en/function.header.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51606
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51606&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51606&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51606&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51606&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51606&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51606&report=yes
Search -- http://master.php.net/manage/user-notes.php