The jquery file upload contains a bunch of files that first need to figure out what the core part is, and according to the official example, one of the simplest jquery file upload upload components must include the following files: The jquery core library, It is recommended to use the jquery 1.8 version Js/vendor/jquery.ui.widget.js:jquery UI widget Js/jquery.iframe-transport.js: Extending the IFRAME data transfer js/ Jquery.fileupload.js:jQuery File upload Core class js/cors/jquery.xdr-transport.js should load this file to solve cross-domain problems under IE
You only need to load one upload button at this time
<input id= "FileUpload" type= "file" Name= "Attch" data-url= "server/php/" multiple>
And one line of code
$ (' #fileupload '). FileUpload ();
A basic upload component is completed. This simplest upload component can submit selected files as forms to the Data-url Convention URL, while providing enough settings and base events to scale.
For the background, you need to increase SPRINGMVC support for uploads, adding configuration to the Springcontext.xml
<bean id= "Multipartresolver" class= "Org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
If you are using MAVEN management, you need to add the following references
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId> commons-fileupload</artifactid>
<version>1.3</version>
</dependency>
The following documents are obtained from the controller
@RequestMapping (value = "/upload/{adid}", method = requestmethod.post) public
@ResponseBody String upload (@ Requestparam (value = "File", Required = False) Multipartfile file, @PathVariable String adid) {
file F=new file (ad_pict Ures_location+adid+ "/" +file.getoriginalfilename ());
try {
fileutils.copyinputstreamtofile (File.getinputstream (), f);
} catch (IOException e) {
E.printstacktrace ();
}
return "Fileuploaddone";
}