wx.chooseImage({
success (res) {
const tempFilePaths = res.tempFilePaths
wx.uploadFile({
url: 'https://example.weixin.qq.com/upload', //仅为示例,非真实的接口地址
filePath: tempFilePaths[0],
name: 'file',
formData: {
'user': 'test'
},
success (res){
const data = res.data
//do something
}
})
}
})
这是官方文档里说的上传图片的方法。
其中wx.uploadFile 里面的 filePath。必须是通过wx.chooseImage所选择的图片吗?
我曾经试过filePath 直接传一个地址,就报错了。