app 使用 uni.uploadFile 上传多文件 服务端只能接收得到一条数据 h5用相同代码没有问题
let fileList = this.$refs.uUpload.lists;
for (var i = 0; i < fileList.length; i++) {
var url=fileList[i].url;
this.files.push({
name:"file:"+url,
uri:url,
});
console.log("uri:"+url);
}
this.uploadFileServer();
}
uploadFileServer(){
console.log("经度:"+this.longitude+"纬度:"+this.latitude);
console.log("files.length:",this.files);
var userToken = uni.getStorageSync("token");
if (this.levelId == 0) {
this.levelId = this.radioList[0].id;
}
uni.showLoading({
title: "提交中...",
})
uni.uploadFile({
url:baseUrl + "app/task/createTask",
files:this.files,
fileType:"image",
formData:{
taskName: this.name,
type: this.eventId,
content: this.content,
usertokencode: userToken,
level: this.levelId,
longitude: this.longitude,
latitude: this.latitude,
address: this.address,
tributary: this.tributary,
},
success:(uploadFileRes)=>{
uni.hideLoading();
console.log("uploadFileRes:"+uploadFileRes.data);
console.log("statusCode:"+uploadFileRes.statusCode);
if (uploadFileRes.statusCode == 200) {
var data=JSON.parse(uploadFileRes.data);
if (data.code == 0) {
uni.showModal({
content: "提交成功",
showCancel: false,
success:function(res){
if(res.confirm){
uni.navigateBack({
delta:1,
})
}
}
})
} else {
uni.showModal({
content: "提交失败:"+data.msg,
showCancel: false,
})
}
} else {
uni.showModal({
content: "提交失败",
showCancel: false,
})
}
},
});
},
},
ReisenU
你好,请问这个问题您有解决吗
2021-05-12 09:44
c***@qq.com
解决了吗
2022-04-12 21:15
1***@qq.com
回复 c***@qq.com: 只能循环调用接口,或者后端修改代码了。
2022-12-22 11:57