'Firefox and Chrome appending underscore before and after file name while Internet Explorer is working fine
Firefox and Chrome are appending underscores before and after the file name while Internet Explorer is working fine.
Firefox and Chrome give: _Warrant_Amendment_5485_14_March_2014.pdf.pdf_
IE gives: Warrant_Amendment_5485_14_March_2014.pdf.pdf
Below is the code
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "inline;filename=\" + fileName + ".pdf\");
Solution 1:[1]
I resolved a similar issue by removing the quotes from the filename value (which in my case were not required).
I note that rfc6266 says a quoted-string for the filename value should be acceptable. At this point I have not investigated further.
Solution 2:[2]
I've just faced the same problem and solved it thanks to user650881's reply.
The problem was I had this:
response.addHeader("Content-Disposition","attachment; filename=" + filename + "\"");
And worked when I changed it to this:
response.addHeader("Content-Disposition","attachment; filename=\"" + filename + "\"");
Note the \"" after filename=
Hope it helps
Solution 3:[3]
This happens when there are characters that are invalid for a file name.
C#'s Path.GetInvalidFileNameChars method lists most.
Round, curly and square brackets may be legal in a file name (it is on Windows), but files with them will also get the underscores added by browsers.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Community |
| Solution 2 | Isidro.rn |
| Solution 3 | trajekolus |
