//获取多张图片
chooseImage: function () {
var that = this;
var res_url = app.globalData.res_url;
wx.chooseImage({
count: 4, // 最多可以选择的图片张数,默认9
sizeType: [‘original’, ‘compressed’], // original 原图,compressed 压缩图,默认二者都有
sourceType: [‘album’, ‘camera’], // album 从相册选图,camera 使用相机,默认二者都有
count: this.data.count[this.data.countIndex],
success: function (res) {
var tempFilePaths = res.tempFilePaths;
// console.log(tempFilePaths)
//console.log(res)
// console.log(‘xxxxxx’)
that.setData({
imageList: res.tempFilePaths,
})
wx.uploadFile({
url: res_url + ‘index.php?g=admin&m=wxxcx&a=release’,
method: “POST”,
header: {
“Content-Type”: “application/x-www-form-urlencoded”,
},
filePath: tempFilePaths[0],
name: ‘file’,
formData: {
‘user’: ‘test’
},
success: function (res) {
var data = tempFilePaths[0]
// console.log(data)
that.setData({
data: tempFilePaths[0],
})
//do something
}
}),
}
})
},
这是我的代码??不知道怎么在后台获取图片??求解
参见 http://www.w3school.com.cn/php/php_file_upload.asp
wx.uploadFile({
url: res_url + ‘index.php?g=admin&m=wxxcx&a=release’,
method: “POST”,
header: {
“Content-Type”: “application/x-www-form-urlencoded”,
},
filePath: tempFilePaths[0],
name: ‘file’,
formData: {
‘user’: ‘test’
},
success: function (res) {
//res 是服务器返回给你的数据
console.log(res)
}
})