|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-03-21 14:58 UTC] pettersen at cpec dot org
Hi,
I believe there is an issue with the header function in 4.1.2 windows Apache module (or it may be a configuration issue on my end, but hear me out =))
First let me state, that I know and understand that IE 5 and 5.5sp1 and even IE 6 have all sorts of issues with content-disposition and how it handles mime-types in general. I don't believe that to be the core issue.
I had a script that worked in 4.1.1 until I upgraded to 4.1.2 (apache module + win 2000) I've cut it down to pretty much as simple as possible to eliminate coding issues on my end.
<?php
header("Expires: Mon, 26 Nov 1962 00:00:00 GMT");
header("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=22119.pdf");
readfile("download/22119.pdf");
?>
This script will cause IE to give the user a "File Open/Save" dialogue box with the correct filename (in this example 22119.pdf) when running on 4.1.1 (which is the desired effect). On 4.1.2 IE will display the "File Open/Save" dialogue box will come up but display the name of the script (download.php for example) and then will display another warning box if you hit "save" stating that it couldn't download the file "download.php" from www.myserver.com.
Of course this functionality works like a dream in Netscape regardless of version.
Thank you in advance for your consideration of this potential issue =)
With best regards,
Erik
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 18:00:01 2025 UTC |
I have had the exact same prob running win 2000 / pro / server and advanced server, IIS and php in CGI mode with PHP 4.3.0RC3. (I have tried the latest PHP version too, cant remember what it is tho). I actually had downloading files working with code that looked like this: <? $rSQL_File_Array = mysql_query(" SELECT * FROM files WHERE id = $file_id "); $rFile_Array = mysql_fetch_array($rSQL_File_Array); $file_type = $rFile_Array["FILE_TYPE"]; $file_name = $rFile_Array["FILE_NAME"]; $file_data = $rFile_Array["FILE_DATA"]; header("Content-Disposition: attachment; filename=$file_name"); header("Content-Description: $file_name"); header("Content-Type: $file_type"); echo base64_decode($file_data); ?> But after changing settings on my router, it doesnt work. To explain, I have my router sending http requests on port 80 through to a LAN server running IIS on port 81. Anyway, after changing IIS to run on port 80 and updating the router respectively, the download page no longer works. Saying that, it didnt work outside the lan anyway. If I requested http://192.168.0.102/download.php the file downloaded, but if I requested the same except using my external IP address (through the router) it didnt work. The error from internet explorer is: Internet Explorer cannot download ...download.php from 192.168.0.102 (or external IP address if that is what I used) The site cannot be found or is unavailable. Interestingly the dialog asking if you want to save the file (just before the error above) doesnt include the file type (it's blank) and the filename is the name of the php file that sends the header info. This IS an issue and should be re-opened!! If I figure out how to do this... I'll post it here! RobOK Here we go, just add session_cache_limiter('public'); before session_start() and the header function will work. Rob