1.需要将请求头的Content-Type设置为multipart/form-data

2.有时候还需要将boundry设置为当前时间戳或者---WebKitFormBoundaryVCFSAonTuDbVCoAN

3.将上传的参数需要使用FormData类型数据,参数和文件以键值对形式放入FormData中
//request封装 export function uploadFile(fd){ return request({ url: ..., method:
'POST', data: fd, header: { 'Content-Type':'multipart/form-data;
boundary=----WebKitFormBoundaryVCFSAonTuDbVCoAN'} }) } //组价中使用 async
myupload(){ const fd = new FormData() fd.append('params1',...)
fd.append('file', this.file) const res = uploadFile(fd) console.log(res) }

技术
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信