图片上传 多张

this.uploadimgs({
   url: app.globalData.baseUrl + 'rest/app/hmpg/opus',  //上传的接口地址 后台提供
   path: imgList//这里是选取的图片的地址数组
});
 



//新增证书图片多张上传 uploadimgs: function (opt) { var that = this; var imgList = that.data.imgs; var opusUuid = that.data.opusUuid; console.log(that.data.opusUuid); for (var i = 0; i < imgList.length; i++) { //图片上传 wx.uploadFile({ //小程序提供的图片上传方法 url: opt.url, //上传地址 filePath: opt.path[i], //图片的数组 name: 'opus ', header: { "Content-Type": "multipart/form-data" }, formData: { //需要上传的除了图片的其他数据 opusUuid: opusUuid, opus: imgList[i] }, success: function (res) { wx.showToast({ //提示弹窗 title: '上传成功!', icon: 'none', duration: 2000//持续的时间 }) }, fail: (res) => { // 上传失败 wx.showToast({ title: '上传失败!', icon: 'none', duration: 2000//持续的时间 }) }, }) } },

注:图片 wx.uploadFile  上传每次只能传一张  多以需要for循环上传

 

原文地址:https://www.cnblogs.com/jinsuo/p/9887985.html