Skip to Content
0
Former Member
Dec 19, 2006 at 02:18 AM

How to encode filename of FileUpload UI element

37 Views

Hi everyone,

I used FileUpload element to upload file to KM folder.<b> It works fine for the English filename, but fails to work for the non-English filename. (Chinese filename</b>). How do I encode the filename to be recognized by the FileUpload API. A piece of my code is as follows:

WDAttributeInfo attInfo = wdContext.nodeFileUpload().getNodeInfo().getAttribute("FileResource");

IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) attInfo.getModifiableSimpleType();

String mineType = binaryType.getMimeType().toString();

byte[] fileData = wdContext.currentFileUploadElement().getFileResource();

File file = new File(binaryType.getFileName());

/Create an output stream for writing to the temperory location/

FileOutputStream out = new FileOutputStream(file);

out.write(fileData);

out.flush();

out.close();

/From the temporary location read the file using an input stream/

FileInputStream fin = new FileInputStream(".//"+file);

<b>binaryType.getFileName() gives me the wrong encoding characters.</b>

Please advice me how to solve this....thanks a lot.

Zita