I've been surfing this up for days now. It appears to be an old problem. I want a user to click on a link to start the download of a file. The code below works in IE only if you comment out the session_start() line. It works either way in Netscape/Mozilla. I have tried every header setting imaginable to get IE to download as a file with no luck. IE offers to download a file with the same name as the php script (download.php) but reports an error when you actually try to accept that file name. any help would be appreciated.
<?
session_start();
header("Content-Type: application/octet-stream");
header("Content-Length: 5");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=\"foo.txt.gz\"");
echo "hello";
?>
Various things I've tried with no success:
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Cache-control: public");
header("Cache-control: private");