While trying to open or save a file with the prompted dialog initalized though phps header function in https mode I use following code.
- In Mozilla/Firefox downloading and instantly opening the file is working
- In IE i can only download the file, but not open it. (Adobe PDF) states that, while opening the file an error occured and that the file does not exist.
Code: Select all
<?php
$fd = @fopen ($path, "rb")
$name = basename($path);
$fsize=filesize($path);
header("Pragma: public");
header("Cache-Control: ");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Content-Type: application/pdf");
header("Content-Disposition:attachment; filename="".trim(htmlentities($name)).""");
header("Content-Description: ".trim(htmlentities($name)));
header("Content-Length: ".(string)$fsize);
header("Connection: close");
while(!feof($fd)) {
$buffer = fread($fd, 4096);
print $buffer;
}
fclose( $fd);
?>On contrary when I use these lines without SSL opening and saving works for both IE and Mozilla/Firefox
Code: Select all
<?php
$fd = @fopen ($path, "rb")
$name = basename($path);
$fsize=filesize($path);
header("Cache-control: private");
header("Content-Type: application/pdf");
header("Content-Disposition:attachment; filename="".trim(htmlentities($name)).""");
header("Content-Description: ".trim(htmlentities($name)));
header("Content-Length: ".(string)$fsize);
header("Connection: close");
while(!feof($fd)) {
$buffer = fread($fd, 4096);
print $buffer;
}
fclose( $fd);
?>Any comment appreciated, thanx _yak