Force IE file download with PHP

March 18th, 2007 by Oliver - Tagged with - Posted in Other Stuff

(No Ratings Yet)
Loading ... Loading ...

I have found a fair few articles on how to force a file download promt with PHP for a recognised MIME type. After spending hours trying different methods I found the following that works for me on IE6+.

header(‘Content-type: application/octetstream’);
header(‘Content-Disposition: attachment; filename=”myfile.pdf”‘);
readfile(“/local/path/to/file/”);
exit();

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>