I have a problem with Internet Explorer 5.5 sp1,sp2 and 6 on NT machine. I am running Zeus web server on a Linux box with PHP Version 4.2.2.
When I send a file with the headers below the suggested file name is not displayed in the save dialog box. Instead the name of the PHP script is the file name
My script is called index.php so the file name in the save dialog is index. It does recognize that I am sending a zip file though. Here is the code.
if(isset($_GET['dlf']))
{
if(isset($_SESSION['authenticated']))
{
if(file_exists("/tmp/".$_GET['dlf']) && eregi('^[A-Z_0-9][A-Z_0-9.]*$', $_GET['dlf']))
{
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: must-revalidate\n");
header("Pragma: public\n");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$_GET['dlf'],".zip\"\n");
header("Content-transfer-encoding: binary\n");
header("Content-length: " .filesize("/tmp/".$_GET['dlf'])."\n");
readfile("/tmp/".$_GET['dlf']);
unlink("/tmp/".$_GET['dlf']);
exit;
}
else
echo "<p class=\"error\">File not found</p>";
}
}
If I send this header:
header("Content-type: application/zip");
the suggested file name is in the save dialog box. But when I try to open the file I get a No CE Signature found error
Any one know how to fix this?
One other note, I have seen headers written with and without a new line character. Which is correct or does it not make a difference.
Doug