if (FileUpload.isMultipartContent(requestCoNtext)) {

 

DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setRepository(new File(savaFilePath));
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setHeaderEncoding("gbk");50MB bytes
upload.setSizeMax(51200000);
List items = new ArrayList();
try {
items = upload.parseRequest(request);
} catch (FileUploadException e1) {
System.out.println("檔上傳發生錯誤" + e1.getMessage());
}

 

Iterator it = items.iterator();
while (it.hasNext()) {
FileItem fileItem = (FileItem) it.next();

 

if (fileItem.isFormField()) {
uploadResult="0";
String name = fileItem.getFieldName();
if (fileItem.getFieldName().equals("username")){
System.out.println("fileItem.toString() "+fileItem.toString()+" "+fileItem.getString());
// }
username=new String(fileItem.getString().getBytes(
"iso8859-1"), "gbk");
System.out.println(fileItem.getFieldName()
// + " 00 "
+ fileItem.getName()
// + " 01 "
+ new String(fileItem.getString().getBytes(
"iso8859-1"), "gbk"));
}
創作者介紹

資訊園

shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()