Before uploading the attachment are used plug-ins, or use form form a physical examination (this is a long time ago), today's whim, to implement the attachment upload, the concrete implementation of the following
Html:
<div>
Flowchart: <input id= "file" type= "file" >
<button ng-click= "bpmmainfunction.createbpm ()" > Submit </button>
</div>
ls|
$scope. bpmmainfunction={
Create BPM
Createbpm:function () {
var file=$ ("#file") [0].files[0];//Get File Object
var form = new FormData (); This is the key.
Form.append ("file", file);//Files Object
$.ajax ({
Url:projectname+ "/testactivity/test",//Background request
Type: ' POST ',
Cache:false,
Data:form,
Processdata:false,
Contenttype:false,
Async:false
}). Done (function (res) {
}). Fail (function (res) {
});
}
}
Java code: (with the Springmvc,multipartfile configuration will not say)
@RequestMapping (value = "Test")
public void Test (@RequestParam ("file") Multipartfile file2) {
Hellowordservice.testproccess ();
Hellowordservice.createproccess ();
Testbpmservice.testproccess (file2);
}
If you have multiple attachments, you can encapsulate the upload by using the Change event of input file
$ ("#file"). Change (function () {
var file=this.files[0]//gets the attachment object, which can be re-submitted through the array encapsulation
})
jquery uploads attachments via Ajax FormData objects