upimg(){
let _this=this;
uni.chooseImage({
count:1,
sizeType:'compressed',
success: (chooseImageRes) => {
const tempFilePaths = chooseImageRes.tempFilePaths;
console.log(this.config+'manage/img/upload');
uni.uploadFile({
url: this.config+'manage/img/upload', //仅为示例,非真实的接口地址
filePath: tempFilePaths[0],
file:tempFilePaths[0],
name: 'img',
formData: {
img:tempFilePaths[0],
},
success: (uploadFileRes) => {
console.log(uploadFileRes.data);
let dat=JSON.parse(uploadFileRes.data)
console.log(dat)
if(dat.code==1){
复制代码 _this.data.images.push(dat.data.url)
}
else{
uni.showToast({
title: dat.data.msg,
icon:"none",
duration: 1000
});
}
},
fail(err) {
console.log(err)
}
});
}
});
},
通过照相机拍摄的图片上传一直走 fail,错误信息:{"errMsg":"uploadFile:fail undefined"}
1 个回复
欢呀
老哥 解决了嘛?我也遇到了