最近在写项目时,在写axios上传文件时不知道咋上传了,来记录一波。
首先上传单个文件
js
var thefile=document.getElementById("files")
var file=thefile.files[0]
const fromdatas=new FormData()
fromdatas.append("File",file)
axios({
url:'/addVideo',
data:fromdatas,
params:{//除文件之外其他的信息
collections:addmoreInput[1].value,
videoId:47,
videoTypes:addmoreInput[2].value,
vips:addmoreInput[3].value
},
method:'post',
})
.then(function (data) {
console.log(data.data);
loading.style.display="none"
handleMessage("添加视频成功")
})
.catch(function(err){
console.log(err);
})
还