Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox and Chrome appending underscore before and after file name while Internet Explorer is working fine

Tags:

java

spring

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\");
like image 454
AKST Avatar asked Mar 18 '14 10:03

AKST


2 Answers

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.

like image 80
user650881 Avatar answered Nov 16 '22 22:11

user650881


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

like image 39
Isidro.rn Avatar answered Nov 16 '22 23:11

Isidro.rn