小程序模板网

小程序上传多张图片到服务器

发布时间:2017-11-08 14:30 所属栏目:小程序开发教程
// 点击选择图片
choose: function (e) {
var that = this
var uniacid = wx.getStorageSync(‘uniacid’)
wx.chooseImage({
count: 9, // 默认9
sizeType: [‘original’, ‘compressed’],
sourceType: [‘album’, ‘camera’],
success: function (res) {
console.log(res)
var img = res.tempFilePaths
var tempFilePaths = new Array(img.length)
// var tempFilePaths = []
console.log(tempFilePaths)
for (let i = 0; i < tempFilePaths.length;i++){
wx.uploadFile({
url: that.data.url + ‘app/index.php?i=’ + uniacid + ‘&c=entry&a=wxapp&do=upload&m=zh_hdbm’,
filePath: img[i],
name: ‘upfile’,
formData: {},
success: function (res) {
tempFilePaths[i] = res.data
that.setData({
tempFilePaths: tempFilePaths
})
},
fail: function (res) {
// console.log(res)
},
})
}
that.setData({
logo: res.tempFilePaths
})
}
})
},


易优小程序(企业版)+灵活api+前后代码开源 码云仓库:starfork
本文地址:https://www.eyoucms.com/wxmini/doc/course/17660.html 复制链接 如需定制请联系易优客服咨询:800182392 点击咨询
QQ在线咨询