Hi there!
It may be off-topic, but i wanna give it a try since this may be a webserver (Apache) configuration issue.
One of our web developers is running crazy about the following situation: He has a php script that delivers a pdf file to the customer. The customer has the choice to "open" (in browser windows) or "save as..." (a file on the local disk).
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?
Thank you & best wishes, Matthias
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; }