如何通过wx.upload实现上传多个图片

通过wx.upload实现上传多个图片


uploadFiles(fileList, name, count, fileName, filePath, fileURLs) {
    var that = this;
    wx.uploadFile({
        url: that.url + "base/uploadFiles.do",
        filePath: fileList[count],
        name: name,
        formData: {
            fileName: fileName + count,
            filePath: filePath
        }, //这里是上传图片时一起上传的数据
        success: function (e) {
            let fileURL = JSON.parse(e.data).fileURL;
            if ('' != fileURLs) {//拼接链接
        	    fileURLs = fileURL + "," + fileURLs
            } else {
         	   fileURLs = fileURL
            }
        },
        fail: function (e) { },
        complete: function (e) {
        count++; //下一张
        if (count == fileList.length) {
      	  //上传完毕,作一下提示
            var strs = new Array();
            strs = fileURLs.split(",");
            that.data.fileURLS = strs
            console.log(fileName+'上传完毕')
        } else {
        //递归调用,上传下一张
       	 	that.uploadFiles(fileList, name, String(count), fileName, filePath, fileURLs);
        	}
        }
    })
}

————————————————
原文链接:https://blog.csdn.net/qq_39753873/article/details/81538039

上一篇:java压缩多个文件


下一篇:Android 上传图片到服务器 okhttp一