var zhi = that.data.inputlist.length - 1;
for(var j=0; j<zhi; j++){
debugger
var pics = that.data.inputlist[j].img;
wx.uploadFile({
url: bbsUrl + ‘?op=-1&mid=’ + wx.getStorageSync(‘mid’),
filePath: pics[j],
name: ‘fileData’,
dataType: ‘json’,
formData: null,
method: ‘POST’,
success: function (resp) {
console.log(“1234567897899” + resp);
}
});
}
递归上传
imgPaths 待上传的所有图片路径数组
currentIndx 当前要上传的图片数组下标,从0开始
oneUpload: function(imgPaths, currentIndx){
var t = this
console.log(‘正在上传第’ + (currentIndx + 1) + ‘张图片’)
wx.uploadFile({
//…
filePath: imgPaths[currentIndx],
success: function (res) {
console.log(‘第’ + (currentIndx + 1) + ‘张图片上传成功’)
// 判断是否还有需要上传的图片
if (currentIndx + 1 < imgPaths.length) {
// 继续上传下一张图片
t.oneUpload(imgPaths, currentIndx + 1)
} else {
console.log(‘所有图片上传成功’)
}
},
fail: function (res) {
console.log(‘第’ + (currentIndx + 1) + ‘张图片上传失败’)
}
})
}