找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索本站精品资源

首页 教程频道 小程序开发 查看内容

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

作者:模板之家 2020-10-12 18:36 16874人关注

小,程序,上传,多张,图片,到,服务器,点击,选择," name=keywords>

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

路过

雷人

握手

鲜花

鸡蛋
原作者: 模板之家 来自: 网络收集

全部回复(0)