0
点赞
收藏
分享

微信扫一扫

通过$.Ajax()方式上传文件,使用FormData进行Ajax请求


 

==============================

我自己的代码:(用vue开发的,用的elementui)

//文件上传
upLoadFile(params) {
console.log("文件上传的参数",params);
var file = params.file;
var that = this;
const form = new FormData();
// 文件对象
form.append("file", file);
$.ajax({
url:"xxxxxx",
type:"post",
data:form,
processData: false,
contentType: false,
success:function(res){
console.log(res);
}
});
},

 



举报

相关推荐

0 条评论