@RequestMapping (value = "Filesupload") Public voidfilesupload (@RequestParam multipartfile[] file, httpservletrequest request, @RequestParam Strin G name, @RequestParam Integer size, @RequestParam string type, @RequestParam string Flagcode, String skuId ) throwsIOException {/*if (Common.notempty (skuId)) {Getimginfo (Flagcode, SkuId, "Mall_" +flagcode+ "" +skuid); }*/List<String> list =NewArraylist<string>(); if(File! =NULL&& file.length > 0) { for(inti = 0; i < file.length; i++) {multipartfile files=File[i]; //Save FileList =saveFile (Request, files, list,name, size, type,flagcode,skuid); } } } PrivateList<string>SaveFile (httpservletrequest request, Multipartfile file, List<String> list,string filename,integer filesize,string filetype,string flagcode,string skuId)throwsIOException {//determine if the file is empty if(!File.isempty ()) { Try { //saved file path (if using a TOMCAT server, the file is uploaded to the \\%tomcat_home%\\webapps\\yourwebproject\\upload\\ folderString uuid =Common.get32uuid (); String Uploadpath=propertiesutil.get ("/module.properties", "Mall.uploadpath"); String Filenmae=File.getoriginalfilename (); String NameType= Filenmae.substring (Filename.lastindexof (".") +1); String Attpath=uuid+ "." +NameType; //savemallattachment (Uuid,filename, FileSize, FileType, attpath,flagcode,skuid);String FilePath = Uploadpath.replaceall ("/", "\\\\") +Attpath; List.add (File.getoriginalfilename ()); File Savedir=NewFile (FilePath); if(!Savedir.getparentfile (). exists ()) Savedir.getparentfile (). Mkdirs (); //Dump Files//File.transferto (savedir);Filecopyutils.copy (File.getinputstream (),NewFileOutputStream (Savedir)); returnlist; } Catch(Exception e) {e.printstacktrace (); } } returnlist; }
Io stream Save upload picture