On Mon, 2005-09-05 at 14:00 +0200, Matthias Hertzog wrote: <SNIP>
The php script declares the data stream as application/octet-stream to force the "open" / "save as..." dialog box in IE. When klicking "save as", the file is stored correctly to the disk. When "open"ing it, acrobat reader opens and tells "unable to finde the file".
Changing the mime-type to application/pdf results in the pdf being opened correctly in the browser window, but the user has no "save as" prompt.
Any ideas?
PHP coder issue, use the "Content-Disposition: attachment;..." header, see the below php script, which is a it-works-for-me thing.
Greets, Jeroen
--
function returnfile($file) { /* Of course one should check if this file is in an allowed path first. Unless one likes to share /etc ;) */ $fp = @fopen($file, "r"); if (!$fp) { header("HTTP/1.0 404 Not Found"); require_once("your404errorpage.php"); return false; }
if ( isset($_SERVER["HTTP_USER_AGENT"]) && strpos($_SERVER["HTTP_USER_AGENT"], "MSIE")) { // IE cannot download from sessions without a cache header("Cache-Control: public");
// q316431 - Don't set no-cache when over HTTPS if ( !isset($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != "on") { header("Pragma: no-cache"); } } else { header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); }
$mime = exec("/usr/bin/file -bin ".$file." 2>/dev/null"); if ($mime == "") $mime = "application/octet-stream"; header("Content-Type: ".$mime);
// Inline text files, don't separatly save them $ext = substr($file, -3); if ($ext != "txt") { header("Content-Disposition: attachment; filename= "".basename($file)."""); }
header("Content-Length: ".filesize($file)); header("Content-Description: Hi SWINOG"); fpassthru($fp); exit; }