前端上传附件方法
页面:
<input id="File1" type="file" accept="*.pdf" @change="saveAttentments" placeholder="附件上传" />
js:
var obj = new FormData();
var file1 = document.getElementById("File1").files[0];
obj.append("ID", OwnerId);
obj.append("subSystem", "insurance");
obj.append("moduleName", "other_attentment");
obj.append("masterType", "other_attentment");
obj.append("attentmentType", "pdf");
obj.append("0", file1);
$.ajax({
url : 'http://10.0.0.15:8080/AABB/' + 'app/uploadFile',
type : 'POST',
data : obj,
contentType : false,
processData : false,
mimeType : 'multipart/form-data',
success : function(data) {
console.log(data);
}
})