[nycphp-talk] Force File Download HTTP Headers and IE Issue
Marc Antony Vose
suzerain at suzerain.com
Wed Sep 3 17:01:30 EDT 2003
>I think this has been addressed in the archives already..
>but maybe not specific to PDF
>
>this works for me. Still prompts to save, but fills in the filename.
>Does it work for you?
>
>
>header("Cache-Control: no-cache, must-revalidate");
>header("Pragma: no-cache");
>header("Content-type: application/octet-stream");
>header("Content-Disposition: attachment; filename=\"$filename\"");
>$fd=fopen("$filePath","r");
>fpassthru($fd);
>
It's worth pointing out, I suppose, that to some systems (i.e.,
classic Mac OS), once you tell the browser that a JPEG (or PDF in
your case) is "application/octet-stream", it is no longer a JPEG (or
PDF).
If this is a controlled Windows environment which relies on simple
file extensions to identify files, you're probably fine, but if you
don't know the types of clients that might connect, you run a risk of
creating problems where people might double-click on the resulting
downloaded file and nothing happenes, because the OS no longer
recognizes it as a JPEG.
Cheers,
--
Marc Antony Vose
http://www.suzerain.com/
Imagination is more important than knowledge.
-- Albert Einstein
More information about the talk
mailing list