NYCPHP Meetup

NYPHP.org

[nycphp-talk] Proper File Downloads Across Browsers

Chris Snyder nyphp at psydeshow.org
Wed Jul 9 12:53:43 EDT 2003


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 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.

   chris.







More information about the talk mailing list