php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16210 Header problem content-disposition
Submitted: 2002-03-21 14:58 UTC Modified: 2002-03-21 17:08 UTC
From: pettersen at cpec dot org Assigned:
Status: Not a bug Package: Output Control
PHP Version: 4.1.2 OS: Windows 2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: pettersen at cpec dot org
New email:
PHP Version: OS:

 

 [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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-21 17:08 UTC] pettersen at cpec dot org
Through trial and error I've determined that in all likely hood this is a config issue on my end somewhere in php.ini (but where!?) =)

I've tried 4.2 RC1 on the win2000 server that had 4.1.1 and the functionality worked fine (still).  On the other server that has 4.1.2 on it (which wasn't working) and putting on 4.2RC1 didn't alleviate the symptom. This leads me to believe that it's a config issue on my end and not a php code issue.

I regret any inconvenience this bogus report may have caused =)

Erik
 [2002-05-28 06:24 UTC] andreas dot kempf at amalesh dot de
Hi,

I got the same problem with PHP4.1.1 and PHP4.2.1 if I install them as the CGI-Version. (Trying to run PHP 4.1.1 and 4.2.1 as a module failed with this error: cannot load php4apache.dll in apache)

After installing PHP4.0.6 via "LoadModule ... php4apache.dll" all is runnning fine.

My System:
W2K SP2, Apache 1.3.23

ciao, Andreas
 [2002-07-04 11:58 UTC] irik at irik dot org
I am seeing this exact behaviour on my system.  I am running linux 2.4 kernel (RH) Apache 1.3.24 and PHP 4.2.1.

Can't seem to figure out why the 'attachment' addendum to the content disposition triggers a save dialog box but the browser (IE 6.x) appears to want to download the php file.

Any help would be great.
 [2003-03-10 11:38 UTC] admin at gemini-ascension dot co dot uk
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!

Rob
 [2003-03-10 12:52 UTC] admin at gemini-ascension dot co dot uk
Well I found how to stop the error, I removed the session_start() at the top of my code (which I didnt show earlier). The file downloads fine then.

Rob

PS, Any ideas how to get it to work WITH sessions?
 [2003-03-10 13:12 UTC] admin at gemini-ascension dot co dot uk
OK Here we go, just add session_cache_limiter('public'); before session_start() and the header function will work.

Rob
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 16:01:31 2024 UTC