Looks like the filename is being sent as utf-8, but being read as Latin1 (can't remember the iso number).

Struts uses Commons FileUpload to handle the file uploads. By default it uses org.apache.struts.upload.CommonsMultipartRequestHandler

Now Commons FileUpload has a method called setHeaderEncoding (- http://jakarta.apache.org/commons/fileupload/apidocs/org/apache/commons/fileupload/FileUploadBase.html#setHeaderEncoding(java.lang.String)

If you can call FileUpload.setHeaderEncoding("utf-8") before the headers are read that should fix the problem. One way to do that is override the default handler with your own one in struts-config.xml eg

<controller multipartClass="my.own.MultiPartClassHandler" />

Then to modify org.apache.struts.upload.CommonsMultipartRequestHandler
by creating our my.own.MultiPartClassHandler class.
We need to modify  the handleRequest() method like so:

 // Create and configure a DIskFileUpload instance.
 DiskFileUpload upload = new DiskFileUpload();

 upload.setHeaderEncoding("UTF-8");

 // Set the maximum size before a FileUploadException will be thrown.
 upload.setSizeMax((int) getSizeMax(ac));
 ...
 ...


Bart Frackiewicz wrote:

Hello,

after uploading a file, getFileName() returns me always a wrong filename, if the filename contains one of the german umlaute (like ü, ä or ö). The filename looks like: "Angebot_Tipps fᅵr Kids.doc" (i display it BEFORE i save the name in the database). This error appears _only_ in the input-file tag, if i enter some characters in a normal input-field, everything goes fine.

Is this a known error? I found nothing in the web. Is here anyone running Struts / upload running succesful with german filenames?

TIA, Bart



--
Jason Lea




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to