1

i have a problem with downloading file name with special characters ( accents ) and spaces . One with extenstion .txt and one without extension.For example : "dokument bez přípony" and "nový textový dokument.txt"

For downloading files in Internet Explorer i am using following:

$name is UTF8

filename="rawurlencode($name)"; filename*=UTF-8''rawurlencode($name)

This is not working ( downloaded with %20 instead spaces )

Content-Disposition: attachment;  filename="dokument%20bez%20p%C5%99%C3%ADpony"; filename*=UTF-8''dokument%20bez%20p%C5%99%C3%ADpony

This is working: ( downloaded properly with spaces if name contains extension )

Content-Disposition: attachment;  filename="nov%C3%BD%20textov%C3%BD%20dokument.txt"; filename*=UTF-8''nov%C3%BD%20textov%C3%BD%20dokument.txt

Any suggestions how to download file without attachment ?

Pavel Perna
  • 359
  • 2
  • 10
  • See this: [Downloads and International Filenames](http://blogs.msdn.com/b/ieinternals/archive/2010/06/07/content-disposition-attachment-and-international-unicode-characters.aspx) – Remy Lebeau Oct 22 '14 at 00:26
  • possible duplicate of [How to encode the filename parameter of Content-Disposition header in HTTP?](http://stackoverflow.com/questions/93551/how-to-encode-the-filename-parameter-of-content-disposition-header-in-http) – Remy Lebeau Oct 22 '14 at 00:27
  • See also: http://stackoverflow.com/questions/93551/how-to-encode-the-filename-parameter-of-content-disposition-header-in-http – Remy Lebeau Oct 22 '14 at 00:28
  • Hi , I've read all the topics you are suggesting me :) And this code is inspired by those articles. But still , i am unable to download such file in Internet Explorer 11 ( important is that only files without extension are not working, if i add any extension to it, it will start to work ) – Pavel Perna Oct 22 '14 at 12:00
  • I also find this , but somehow i am unable to understand the answer , it is the same-like problem http://answers.microsoft.com/en-us/ie/forum/ie8-windows_xp/content-disposition-filename-with-space-and/bf22b813-689f-4a8d-9864-9f0b089eb439 – Pavel Perna Oct 22 '14 at 12:01
  • I did some testing with IE11 and it is only `%20` that it has a problem with when no extension is present. You can use actual spaces instead and IE11 is quite happy with that, it will still decode the UTF-8 portion: `Content-Disposition: attachment; filename="dokument%20bez%20pripony"; filename*=UTF-8''dokument bez p%C5%99%C3%ADpony` – Remy Lebeau Oct 22 '14 at 18:35
  • Huh, nice trick :) It is working , so now i do `filename="rawurlencode($name)"; filename*=UTF-8''str_replace('%20',' ',rawurlencode($name))` for IE purposes , its a bit dirty , but it works , thank you – Pavel Perna Oct 23 '14 at 10:21
  • It is not uncommon for servers do have to do different things for specific browsers. They don't all conform to the same standards in the same way (which kind of defeats the purpose of having standards). – Remy Lebeau Oct 23 '14 at 17:18

0 Answers0