You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by roy huang <li...@hotmail.com> on 2004/04/21 16:41:20 UTC

[Help]How to get uploaded file name using different form-encoding(ever post in user mail-list)?

I post this mail yestoday,no one response,so I repost here hope get help.

Hi,all:
    This's a strange question stuff me up.I set form-encoding to utf-8 in web.xml for display and submit.I can use this code to get the correct string in Chinese,the form encoding is utf-8:
    userName = new String(request.getParameter(nameField).getBytes("ISO-8859-1"));
    But in the same time I use an activex control to upload file,the control is to generate an html form and submit ,it's form encoding is ISO-8859-1,here comes the problem.
    code:
     Part part = (Part) request.get(this.fileField);
     String tmp = part.getFileName();
     String fileName = new String(tmp.getBytes("ISO-8859-1"));
    the Chinese fileName becomes something like ???????????????????.pdf.
    I try to solve it:
    1.If I change form-encoding back to default,the fileName is ok,but my other application using utf-8 encoding is wrong
    2.I use SetCharacterEncodingAction like:
   <map:act type="formencoding">
    <map:parameter name="form-encoding" value="ISO-8859-1" />
   </map:act>
   ... upload thing
   but it doesn't work ,though I print the request.getCharacterEncoding() and see "ISO-8859-1",I believe the fileupload is still using the default form-encoding utf-8.

How can I solve this problem?

Roy Huang