Page 1 of 2

Download file with Unicode file name

Posted: Mon Nov 28, 2011 8:09 am
by dollylamb
Hi,

Is jFileDownload supports download file with Unicode file name? I tried jFileDownload with Unicode file and the result is always: Download failed: <file> not found.

Thanks

Re: Download file with Unicode file name

Posted: Mon Nov 28, 2011 8:30 pm
by support
Yes, it works. See screenshot below with Japanese characters. I guess you have a problem with encoding.
screenshot.png
Applet with Japanese file download
(76.49 KiB) Not downloaded yet
Make sure you have:
In HTML:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
In JavaScript:
document.writeln('<PARAM NAME="encoding" VALUE="UTF-8">');
In server-side script (i.e. for JSP)
...
String encoding = "UTF-8";
...
request.setCharacterEncoding(encoding);
response.setContentType("text/html; charset="+encoding);
...
I also enclose a full working/tested sample for JFileUpload + JFileDownload + JSAPI 2.9 Pro:
JFD-JSAPI2.9.zip
Full sample 2.9
(4.86 MiB) Downloaded 13947 times
Does it help?

Re: Download file with Unicode file name

Posted: Tue Nov 29, 2011 1:38 am
by dollylamb
Many thanks. I'll try and let you know.

Re: Download file with Unicode file name

Posted: Tue Nov 29, 2011 3:44 am
by truongvu
I also have this problem .
I tested on Windows 7 but it still display 'Donwload failed: cars_1918要求仕様書.jpg not found' !
I think this sample run well on Linux . Can it run well on Window ?

I use PHP but I can't find code for encoding UTF-8 in server script . Where can I put it ?
Thanks for reply !

Re: Download file with Unicode file name

Posted: Tue Nov 29, 2011 7:23 am
by support
Sample was tested under JRE 1.6 + Tomcat 6 + Windows Vista.
Double check encoding support in PHP, see:
http://htmlpurifier.org/docs/enduser-utf8.html
or
http://www.phpwact.org/php/i18n/charsets

Re: Download file with Unicode file name

Posted: Thu Dec 01, 2011 8:09 am
by dollylamb
Hi,

Using your new 2.9 sample script doesn't help much. I still facing "File not found" problem. Below are what i have done:
- Set javascript & html page encode to UTF-8
- Set server side script encode to UTF-8

However, in server side script if I download a file with non-latin file name then the script stop right after "list" command.

Any ideas?

Re: Download file with Unicode file name

Posted: Fri Dec 02, 2011 4:09 am
by dollylamb
Hi,

It seems like there was a wrong file name comparison in getHTTPRemoteTFile function (wrong encoding or something?) so server side script never has a chance to be called ?

Re: Download file with Unicode file name

Posted: Fri Dec 02, 2011 7:27 pm
by support
Or it may be a problem in you server-side script. It works fine here. We've tested with Japanase file + JSP/TOMCAT/JRE1.6

Re: Download file with Unicode file name

Posted: Tue Dec 06, 2011 6:38 am
by dollylamb
Hi,

Server side script never be called, so i doubt it is a server side script problem. I used your downloader with PHP + IIS web server not JSP + Apache Tomcat. Have you ever tested your downloader with above server spec? However, i'll try JSP + Tomcat if it works. Thank you for your support.

Re: Download file with Unicode file name

Posted: Fri Sep 21, 2012 3:34 pm
by vlad
I am also having a problem with UTF-8 encoded file names. I have a script that lists files and JFileDownload is making proper HTTP requests back to download each file. It has the filenames right, as the server side script is able to provide the requested downloads. However, I believe JFileDownload is not decoding the filename from UT-8 before saving it to disk.
The filename "Iñtërnâtiônàlizætiøn.rar" ends on the disk as "Iñtërnâtiônàlizætiøn.rar". The same messed up name is also displayed in the applet, while downloading.
The server is providing the following headers:

Code: Select all

Content-Type: application/download; charset=UTF-8
Content-Disposition: attachment; filename="Iñtërnâtiônàlizætiøn.rar"
The Java applet should decode the "filename" using the provided charset. All browsers work perfectly fine with the same script, so I assume the problem is from JFileDownload.