vue中用ajax上传文件

直接上代码

<input class="file-btn" type="file" @change="uploadCompany($event)" name="uploadCompany"  v-model="filename" accept=".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"/>

vue中用ajax上传文件

uploadCompany: function(event){
this.file = event.target.files;
let formdata = new FormData()
formdata.append('file', this.file[0])
formdata.append('submit', false);
$.ajax({
url: api.url+"Excel/importQyInfo",
data: formdata,
type: "POST",
dataType: "json",
cache: false, //上传文件无需缓存
processData: false, //用于对data参数进行序列化处理 这里必须false
contentType: false, //必须
success: function (res) {
console.log("上传完成!",res);
},
})
}

上一篇:Git各种错误汇总


下一篇:【app】自动化环境搭建(Appium)for java