firefoxheadercontent-disposition

Firefox and Content-Disposition header


I have a problem with an attachment's name. When I call the site on google chrome it returns the file with the right name and extension. I tested it with internet explorer and it works fine too. The issue lies with only Firefox. I call the site and it returns the first word on the file title and no extension.

For example if I wanted a file called "My report.docx" it turns a file called "My". I Googled around and it turns out this is a common issue with people because browsers read the headers differently. They said the fix is to quote the file name:

Content-Disposition: attachment; filename=My Report.docx

is now: (note the quotes)

Content-Disposition: attachment; filename="My Report.docx"

However, that did not work for me.

On chrome it returned "My Report.docx" (actually with the quotes). Firefox returned a odd file that had the proper extension and proper name and no quotes yet it could not be executed. It was the proper file size, proper extension, and proper name yet it could not be executed. Also it returns a space before and after the file name.


Solution

  • This should work as expected, here's another SOq with the same problem:

    and also the Mozilla page (I guess you were referencing this one):

    I don't know the specifics of your server side code, but here are some things to confirm / try:

    Hope this helps.