NYCPHP Meetup

NYPHP.org

[nycphp-talk] Proper File Downloads Across Browsers

Hans Zaunere hans at nyphp.org
Wed Jul 9 15:29:58 EDT 2003



Chris Snyder wrote:

> The header combination I've had the most luck with looks like:
> 
>> Content-Disposition: attachment; 
>> filename="mx1200-photos-2002-02-12-coffee[1].zip"
>> Content-Length: 181041
>> Cache-Control: private
>> Content-Type: application/x-zip-compressed

I forgot about the Content-Length;  that's probably a good call in general.

> I still have some users who have to right-click and choose Save Target As.
> I don't know of a magic MIME-type that works for all files, I thought
> application/octet-stream was it, but if IE has associated that with zip
> (or any other filetype) in the past, then good luck.
> 
> In other words, the MIME-type is more of an associative hint to the
> browser-- if you use application/x-crystal-report, and instruct your
> users to associate that with the proper application, then it will work
> from there. If the reports are plain-text or html, then use the
> appropriate mime type -- of course IE may act broken and try to suggest
> a filename suffix that it will understand later when it doesn't have the
> benefit of a content-type header to guide it. It's frustrating, but you
> can see why they made it that way.

I can? :)

In my situation, the user won't have a registered application for the file they download, so my best bet will be to force a download.  Oddly enough, I've found if you put application/lalala (gibberish) as the MIME  sub-type, all browsers will download it.  So, by default, not design - ahh, good ol' MIME

Thanks,

H





More information about the talk mailing list