//为控件添加mutile属性 $("#"+unieap.getRealId("fileInput1")).attr("multiple","multiple"); //获取多文件上传时每个文件的值 $("#"+unieap.getRealId("fileInput1")).change(function () { var length=this.files.length; for(var i=0;i<length;i++ ){ alert(this.files[i].name); } });
var dc=new unieap.ds.DataCenter(); dc.addHeaderAttribute("formId", "form1"); view.processor.updateFile(dc);
@Override @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Path("/uploadFile") public void updateFile(@Context HttpServletRequest request) { boolean isMultipart = ServletFileUpload.isMultipartContent(request); if(isMultipart){ FileItemFactory factory=new DiskFileItemFactory(); ServletFileUpload upload=new ServletFileUpload(factory); upload.setHeaderEncoding("UTF-8"); List<FileItem> list=null; try { list=upload.parseRequest(request); for(FileItem file:list){ if(file.isFormField()){ //普通表单值 System.out.println(file.getString()); //TODO }else{ String fileName=file.getName(); System.out.println(fileName); InputStream input = file.getInputStream(); //TODO进行一些文件上传操作 } } } catch (FileUploadException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
Powered by codetiler.com