1:download apache commons-fileupload
2:example:
DiskFileItemFactory factory = new DiskFileItemFactory();
// Set factory constraints
factory.setSizeThreshold(2048*1000);
factory.setRepository(new File(rootpath));
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
// Set overall request size constraint
upload.setSizeMax(2048*1000);
// Parse the request
List /* FileItem */ items = upload.parseRequest(request);
Iterator iter = items.iterator();
FileItem fileItem=null;
Accouter accouter=new Accouter();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
if (item.isFormField()) {
System.out.println(item.getFieldName()+":"+item.getString());
} else {
//String fileName = item.getName();
//String contentType = item.getContentType();
//boolean isInMemory = item.isInMemory();
//System.out.println(fileName+":"+contentType+":"+isInMemory);
//item.write(new File(rootpath+"filetemp/1212.png"));
}
}