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

  • • 发表于 8年前
  • • 作者 突然上蹿下跳吃桶跳跳糖
  • • 4745 人浏览
  • • 5 条评论
  • • 最后编辑时间 8年前
  • • 来自 [技 术]

原创声明:本文为作者原创,未经允许不得转载,经授权转载需注明作者和出处

// 点击选择图片
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
})
}
})
},

分享到:
5条评论
Ctrl+Enter
作者

突然上蹿下跳吃桶跳跳糖

突然上蹿下跳吃桶跳跳糖

APP:0 帖子:7 回复:4 积分:99

已加入社区[2881]天

นอนอัมพาตขึ้นไง

作者详情》
Top