It has been discussed before, but there are many problems when getting a download script to work with different browsers. The code below actually works with IE5.5 PC and IE5+ Mac, and most browsers I've tested. However, it only shows up a blank page for Opera 6.01. I've tried everything, but I can't get Opera to play ball. Any advice anyone has would be greatly appreciated.
///////////////////////
<?
if (isset($file) and isset($name)) {
if(strstr($HTTP_USER_AGENT, 'MSIE 5.5')) {
$fp = fopen($file,"rb");
$fsize = filesize($file);
header("Content-type: application/download\r\n");
header("Content-length: $fsize\r\n");
header("Content-disposition-type: attachment\r\n");
header("Content-disposition: filename=$name");
$result = fpassthru($fp);
exit;
} else {
header ("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=$name");
header ("Content-Transfer-Encoding: binary");
}
}
?>
///////////////////////
(PS: I'm trying to get the browser to download an image (not display it), so everytime Opera doesn't render a blank page, it just shows the image).