报错信息:
VM6374:1 uploadFile:fail createUploadTask:fail Error: Invalid URL passed to App.getProxyForURL()'
upFileHandler () {
wx.chooseImage({
count: 1,
success (res) {
const tempFilePaths = res.tempFilePaths
wx.uploadFile({
url: '',
filePath: tempFilePaths[0],
name: 'image',
formData: {
'imgIndex': 0
},
header: {
"Content-Type": "multipart/form-data"
},
success: function (res) {
var data = JSON.parse(res.data);
}
});
}
})
}
??? 官方人没人理?
麻烦提供能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
upFileHandler () {
wx.chooseImage({
count: 1,
success (res) {
const tempFilePaths = res.tempFilePaths
// tempFilePaths[0] -> http://tmp/wx47292e19a83b70a2.o6zAJs4K2DBooYSRIZKPzqGyX0JU.lMeMD2yX89WWf0be879ebe2af232739edf76c3432313.jpg
wx.uploadFile({
url:
''
,
filePath: tempFilePaths[0],
name:
'image'
,
formData: {
'imgIndex'
: 0
},
header: {
"Content-Type"
:
"multipart/form-data"
},
success:
function
(res) {
var
data = JSON.parse(res.data);
}
});
}
})
}
整理一下格式,在调用这个方法时,就会报错
uploadFile:fail createUploadTask:fail Error: Invalid URL passed to App.getProxyForURL()'