uniapp写小程序图片上传报错 uploadFile:fail createUploadTask:fail url not in domain list
uni.chooseImage({
count: 1,
sizeType: ['compressed'],
success(res) {
var tempFilesSize = res.tempFiles[0].size; //获取图片的大小,
if (tempFilesSize <= 10000000) { //图片小于或者等于10M时 可以执行获取图片
const tempFilePaths = res.tempFilePaths; //获取图片
// 上传图片
uni.uploadFile({
url: uni.$url+'/xxx',
filePath: tempFilePaths[0],
header: {
sessionId: uni.getStorageSync('sessionId'),
},
name: 'file',
formData: {
bizType: "patient",
},
success(r) {
console.log(r)
},
fail:(e)=>{
console.log(e,'上传图片异常原因')
}
})
setTimeout(() => {
that.setData({
disabled: false,
loading: false
})
}, 7000)
that.setData({
disabled: true,
loading: true
})
} else { //图片大于2M,弹出提示框
uni.showToast({
title: '上传图片不能大于10M!', //标题
icon: 'none'
})
}
},
fail() {}
})