yangyi
项目合作联系我: yangyi_love@hotmail.com

导航

 

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"));
       }
   }

posted on 2008-11-28 14:21  谁是菜鸟?  阅读(921)  评论(1编辑  收藏  举报