commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Priest <Robert.Pri...@bentley.com>
Subject RE: [FileUpload] Unicode Encoding for a Form
Date Wed, 17 Sep 2003 15:38:25 GMT
and the following does not help:

 try
  {
  fileName = new String(cd.substring(start + 10,
end).trim().getBytes("UTF-8"));
  }
 catch (java.io.UnsupportedEncodingException uee)
  {
  }

-----Original Message-----
From: Robert Priest [mailto:Robert.Priest@bentley.com]
Sent: Wednesday, September 17, 2003 11:19 AM
To: 'commons-user@jakarta.apache.org'
Subject: [FileUpload] Unicode Encoding for a Form


Hello all,

I have a simple html form which has an <INPUT TYPE="FILE"/> field in it.

Now when I select a file that contains Scandanavian characters (such as
umlauts) it is not being URL encoded properly before being sent. As a
result,  my jsp page which accepts posts of files via the FileUpload package
is not interpreting the file name correctly.

Has anyone seen this problem, first? And does anyone have a solution for
this issue?


For example, if I select a file say:

filename="C:\Documents and Settings\Robert.Priest\Desktop\รครครค.txt"

what is sent in the request is:

C:\Documents and Settings\Robert.Priest\Desktop\???.txt"


and what is seen by if you do a FileItem.getName() is:

C:\Documents and Settings\Robert.Priest\Desktop\???.txt


So the method FileUploadBase.getFileName(Map /* String, String */ headers)
does not see the correct filename when it executes: 

 if (start != -1 && end != -1)
            {
                fileName = cd.substring(start + 10, end).trim();
            }


The following is the multipart requests that IE sends using such a file
(with umlauts) in the name:
------------------------------


POST /jsp/upload.jsp HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/vnd.ms-
powerpoint, application/vnd.ms-excel, application/msword,
application/x-shockwav
e-flash, */*
Referer: http://localhost:8080/roberttest/rptest.html
Accept-Language: en-us
Content-Type: multipart/form-data;
boundary=---------------------------7d39eb580
29a
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
Host: localhost:2000
Content-Length: 349
Connection: Keep-Alive
Cache-Control: no-cache

-----------------------------7d39eb58029a
Content-Disposition: form-data; name="oFile1"; filename="C:\Documents and
Settin
gs\Robert.Priest\Desktop\???.txt"
Content-Type: application/octet-stream


-----------------------------7d39eb58029a
Content-Disposition: form-data; name="TestValue"

AAAAA
-----------------------------7d39eb58029a--



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message