Hi,
I am trying to make a download manager, which forces files to be downloaded, rather then be opened in the browser.
Code below works when used in Opera, but failes in IE (In ie it will open .txt files, and ignore pdf files. .exe are downloaded, as per default setting)
Any ideas?
// ---------------------------------------------------------------------------------
If($download == "true")
{
// Insert details
$downloadinsert = mysql_query("insert into downloads (D_user, D_file) values ('$userid', '$file') ");
$dbn = "".$thisfile."";
$fp = fopen($dbn, "rb");
$sdata = fread($fp, filesize($dbn));
fclose($fp);
if (strstr($_SERVER["HTTP_USER_AGENT"],"MSIE 5.5"))
{
$att = "";
}
else
{
$att = " attachment;";
}
header('Cache-control: max-age=31536000');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-Length: '.filesize($dbn).'');
header('Content-Type: application/download; name="'.$thisfile.'"');
header('Content-Disposition:'.$att.' filename="'.$thisfile.'"');
header('Content-Transfer-Encoding: binary');
echo $sdata;
// ---------------------------------------------------------------------------------
}