多文件上次,后台循环去接收,前端这样写:```javascript
let imgs;
if (this.imageList.length != 0) {
imgs = this.imageList.map((value, index) => {
return {
name: "file" + index,
uri: value
}
});
} else{
imgs = '';
}
uni.uploadFile({
url: this.$serverUrlhunlian + '/user/editUserdataFile',
methods: 'POST',
files: imgs,
filePath: '',
name:'file',
formData: jsons,
header: {
'Content-Type': 'multipart/form-data',
'token': this.$store.state.user.token,
},
success: (res) => {
uni.hideLoading();
var dat = JSON.parse(res.data);
console.log(JSON.stringify(dat));
// {"msg":"操作失败","flag":false,"status":"error"}
if (dat.flag) {
uni.hideLoading();
uni.showToast({
title: '修改成功!'
});
setTimeout(function(){
uni.navigateBack({
delta: 1
})
}, 1000)
}else{
uni.showToast({
title: '提交失败,请检查是否有特殊字符',
icon: 'none'
})
}
},
fail: (res) => {
//console.log(res);
uni.hideLoading();
uni.showToast({
title: '请求失败,请检查网络',
icon: 'none'
})
}
});
选择图片: ```chooseImg() { //选择图片
uni.chooseImage({
sourceType: ["camera", "album"],
sizeType: ["compressed"],
count: 6 - this.imageLists.length - this.imageList.length,
success: (res) => {
//console.log(JSON.stringify(res))
this.imageList = this.imageList.concat(res.tempFilePaths);
}
})
},```