小程序模板網(wǎng)

小程序上傳多張圖片到服務(wù)器

發(fā)布時(shí)間:2017-11-08 14:30 所屬欄目:小程序開發(fā)教程
// 點(diǎn)擊選擇圖片
choose: function (e) {
var that = this
var uniacid = wx.getStorageSync(‘uniacid’)
wx.chooseImage({
count: 9, // 默認(rèn)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
})
}
})
},


易優(yōu)小程序(企業(yè)版)+靈活api+前后代碼開源 碼云倉(cāng)庫(kù):starfork
本文地址:http://22321a.com/wxmini/doc/course/17660.html 復(fù)制鏈接 如需定制請(qǐng)聯(lián)系易優(yōu)客服咨詢:800182392 點(diǎn)擊咨詢
QQ在線咨詢