wx.chooseImage({
count: 3,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success (res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
console.log(tempFilePaths)
wx.request({
url: 'http://127.0.0.1:8002/wx_uploadToken',//获取上传token
success(res){
console.log(res.data.uptoken)
for(let i = 0;i<3;i++){
wx.uploadFile({
url: 'https://up-z0.qiniup.com',//对应七牛区域
name: 'file',
filePath: tempFilePaths[i],
header: {
"Content-Type": "multipart/form-data"
},
formData: {
token: res.data.uptoken,
},
success: function(ress) {
console.log('qiniu');
console.log(ress);
},
fail: function(res) {
console.log(res)
}
});
}
}
})
}
})
微信小程序上传图片到七牛
最新推荐文章于 2023-11-27 18:33:54 发布