I have a section of my website where customers can login and download a few
select files.
The download links are to php scripts that decide which files to download.
Generally it works fine. However I have one browser compaibilty problem and
an annoyance with MS Internet Explorer
With IE if the user cancels the download (they are only small downloads so
this is unlikely) the browser will stop working corectly from then on: All
links on the page will stop working until the browser is closed and
reopened.
With the Avant Browser (http://www.avantbrowser.com ) Downloads fail as the
DL script seems to bump the user to the customer login page.
Here's the code:
<?php
//Generic PHP Header Commands
session_start();
//Check the Customer is Logged In and kick them if they aren't (I think this
is where avant browser fails)
if( !$_SESSION['CustomerID'] )
{
header("Location: http://{$_SERVER['HTTP_HOST']}" .
dirname($_SERVER['PHP_SELF']) . '/cust-login.php');
exit();
}
//then I get some data about the filename from our database and assign the
correct filename to $filepath
//I've deleted this section because it is irrelevant to this problem
//here's where I output the file
$fp = fopen($filepath, "rb");
// send the right headers
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$urlfilename."\"");
header("Content-Length: ".filesize($filepath));
fpassthru($fp);
exit;
?>
PHP version is: 4.1.2 and I'm using the latest versions of IE and avant
browser running under Windows 2000
Really appreciate any help from any php masters!
-Nick.