note 74736 added to function.header
| From: | BrandonK | Date: | Wed, 25 Apr 2007 19:34:43 +0000 |
| Subject: | note 74736 added to function.header | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125862@lists.php.net to get a copy of this message | ||
I just lost six hours of my life trying to use the following method to send a PDF file via PHP to
Internet Explorer 6:
<?php
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="downloaded.pdf"');
readfile('original.pdf');
?>
When using SSL, Internet Explorer will prompt with the Open / Save dialog, but then says "The
file is currently unavailable or cannot be found. Please try again later." After much
searching I became aware of the following MSKB Article titled "Internet Explorer file downloads
over SSL do not work with the cache control headers" (KBID: 323308)
PHP.INI by default uses a setting: session.cache_limiter = nocache which modifies Content-Cache and
Pragma headers to include "nocache" options. You can eliminate the IE error by changing
"nocache" to "public" or "private" in PHP.INI -- This will change the
Content-Cache header as well as completely remove the Pragma header. If you cannot or do not want
to modify PHP.INI for a site-wide fix, you can send the following two headers to overwrite defaults:
<?php
header('Cache-Control: maxage=3600'); //Adjust maxage appropriately
header('Pragma: public');
?>
You will still need to set the content headers as listed above for this to work. Please note this
problem ONLY effects Internet Explorer, while Firefox does not exhibit this flawed behavior.
----
Server IP: 69.147.83.197
Probable Submitter: 70.62.40.253
----
Manual Page -- http://www.php.net/manual/en/function.header.php
Edit -- https://master.php.net/note/edit/74736
Del: integrated -- https://master.php.net/note/delete/74736/integrated
Del: useless -- https://master.php.net/note/delete/74736/useless
Del: bad code -- https://master.php.net/note/delete/74736/bad+code
Del: spam -- https://master.php.net/note/delete/74736/spam
Del: non-english -- https://master.php.net/note/delete/74736/non-english
Del: in docs -- https://master.php.net/note/delete/74736/in+docs
Del: other reasons-- https://master.php.net/note/delete/74736
Reject -- https://master.php.net/note/reject/74736
Search -- https://master.php.net/manage/user-notes.php