Hi,
I have a PHP script that uses either readfile, fpassthru or print (have
tried all three to fix the problem I'm about to describe) to download a file
to a browser. I want to force download rather than display in the browser.
It works fine except for one problem. In IE 5.0 after the download has
completed and the download dialogue box has gone, the browser is displaying
the egg timer icon for the cursor, as if it's still waiting for the download
to complete. In one IE 6.0.26 it's not doing this. In IE6.0.28 SP1 the egg
timer does not appear, but the browser seems to lock up for a while when I
click on a link after doing a download.
The code is below and within the comments are some of the variations I used
for headers and the actually file pass through bit as well, that I've seem in this board.
Thanks,
Kevin
$file is the filename and $path is the complete path to the file
//force download dialog
header("Content-type: application/octet-stream");
// header("Content-Type: application/save");
// set file name of downloaded file
header("Content-length: " . filesize($path));
//header("Content-transfer-encoding: binary");
header("Content-disposition: attachment; filename=$file");
#send file contents
readfile($path);
//fpassthru($fp);
/*
$fp=fopen($path, "r");
while(!feof($fp)) {
$buffer = fread($fp, 4096);
print $buffer;
}
fclose($fp);
fflush(); # this may not be needed
exit();
$size = filesize( $filename );
header("Content-Type: application/save");
header("Content-Disposition: attachment; filename=$shortname");
$fh = readfile("$filename"); # I use this instead of fopen because when
fopen is used, it only reads 1KB of data
fpassthru($fh);
*/