I have a script, it generates a file on the servers filesystem (unnecessary I know, but it's the way it is right now)
Then I run the following...
Where $filepath is the full path to the file and $filename is what it says. (For the record I've also tried Content-type=text/plain)
This all works perfectly in Firebird... but in IE, if I choose save, it works fine. If I choose open it asks me again.... so I choose open again... then, once in a rare while it works, but mostly it says the file cannot be found (and lists out a file in the temporary internet files folder).
Tinkering right now as I write this it seems whether or not it works depends on how long I wait before clicking the second open... if I click it right away, it's a failure, if I wait, it works... so my guess is it's actually downloading the file there.
Then I run the following...
Code:
if (is_file($filepath)) {
$len=filesize($filepath);
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
$filename = preg_replace('/\./', '%2e', $filename,
substr_count($filename, '.') - 1);
}
header("Pragma: ");
header("Cache-Control: max-age=30, no-cache ");// header("Cache-Control: ");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".trim(htmlentities($filename))."\"");
header("Content-length: $len");
header("Connection: close");
if ($fp=fopen($filepath, "rb")) {
fpassthru($fp);
die;
}
else {
myHeader();
echo 'ERROR: Could not open '.$filepath;
die;
}
}
Where $filepath is the full path to the file and $filename is what it says. (For the record I've also tried Content-type=text/plain)
This all works perfectly in Firebird... but in IE, if I choose save, it works fine. If I choose open it asks me again.... so I choose open again... then, once in a rare while it works, but mostly it says the file cannot be found (and lists out a file in the temporary internet files folder).
Tinkering right now as I write this it seems whether or not it works depends on how long I wait before clicking the second open... if I click it right away, it's a failure, if I wait, it works... so my guess is it's actually downloading the file there.