如何使用js将文件的参数传入到后台
作者:互联网
页面代码:
#js 代码 function onUpload(val) { var fileId="file_"+val; var formData = new FormData();
// 获取文件
var fileData = $("#"+fileId).prop("files")[0];
// var fileData = $("#file").prop("files")[0];
console.log(fileData);
debugger;
formData.append("file", fileData);
formData.append("id",val);
// formData.append("goodsName",goodsName);
// formData.append("xinhao",xinhao);
$.ajax({
url: '/zhijianfilesuploadhuihuo',
type: 'POST',
async: false,
data: formData,
cache: false,
contentType: false,
processData: false,
success: function (data) {
//alert(data);
}
});
}
、、 @RequestMapping(value = "zhijianfilesuploadhuihuo",method = RequestMethod.POST)
public String zhijianfilesupload(MultipartFile file,
@RequestParam(name = "id",required = false)Long id,
标签:false,传入,formData,js,var,file,后台,fileData,append 来源: https://www.cnblogs.com/pdxt666/p/16186000.html