epalla

A
u
g
19

PDFs from a Database with IE

August 19th 2009 4:38 pm by Matt

Apparently IE (including IE7) is retarded when it comes to live downloads from a database. This problem manifests itself in particular when it comes to downloading PDFs. That means when you try to load a pdf out of a database with the following incredibly common code snippet:

header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$name");

you can “Save Target As” with IE but not actually open it directly from a link. It works fine in Firefox. After much obnoxious tinkering and searching, I discovered that adding:

header("Cache-control: private");
header("Pragma: public");

just makes it magically work.

Make me popular!

    This entry was posted on Wednesday, August 19th, 2009 at 4:38 pm and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

    Comments are closed.