Jump to content

[SOLVED] session_start causings problems with IE


fanfavorite

Recommended Posts

I have a script that downloads mp3 files from outside the web directory.  It works great on all browsers except Internet Explorer.  I have simplified the script to better show what is happening.  Basically if I remove the "session_start", the script downloads fine on Internet Explorer, however if it is there, it will not work.  The code is:

 

<?
session_start();
$file_name = "SomeFile.mp3";
$file_path = "/path/to/files/";

header("Content-Type: application/unknown");
header("Content-Disposition: filename=$file_name");

if($fp = fopen($file_path.$file_name, "r")) {
while(!feof($fp)) {
	echo  fgets($fp, 4096);
}
fclose($fp);
}
?>

 

I have read about "zlib.output_compression", however this is already set to off.  Any help is appreciated.  Thanks. 

Are you sure the session_start() is not triggering a php error and the error message being output to the browser is content that is preventing the other headers from working?

 

Just as a test, add the following line immediately after your <?php tag -

 

ini_set ("display_errors", "0");

I actually just came across this article http://joseph.randomnetworks.com/archives/2004/10/01/making-ie-accept-file-downloads/. 

 

Adding:

 

if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {

    session_cache_limiter("public");

}

 

above the session_start(); seems to work. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.