Hbuildx : 3.1.9.20210413
真机:华为P30 pro
EMUI:11.0.0
Android:10
去年12月份的时候拍照和相册选择都可以,最近做更新发现拍照没有问题,但相册选择在upload的时候直接fail,fail代码为:
{"errMsg":"uploadFile:fail undefined"}
请帮忙分析下原因,期间并未修改这块代码。如果是bug的话请问什么时候能修复呢?
代码如下:
chooseImg(){
uni.chooseImage({
count: 1,
sourceType: ['camera','album'],
success: function(res){
_self.uploadImg(res.tempFilePaths[0]);
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePaths[0],
success: function(){
}
});
},fail: function(res){
uni.showToast({
icon: 'none',
title: 'res.errMsg'
});
}
});
}
uploadImg(filepath){
uni.showLoading({
title: '上传中,请稍后...'
});
const jsondata = {};
jsondata.header = {time: Date.now(), token: _self.token};
jsondata.body = {"signature":"111"};
console.log(filepath);
uni.uploadFile({
url: peizhi.apiurl + 'api/common/upload',
fileType: 'image',
filePath: filepath,
name: "imageField",
formData: jsondata,
success: function(res){
var resdata = JSON.parse(res.data);
if(resdata.error_code == 0){
uni.showToast({
icon: 'none',
title: resdata.msg
});
_self.arrpic.push(filepath);
_self.picurl.push(resdata.data);
if(_self.arrpic.length>=4){
_self.showadd = false;
}
console.log(1111111111);
uni.hideLoading();
}else{
uni.showToast({
icon: 'none',
title: '上传失败'
});
uni.hideLoading();
}
},fail: function(res){
console.log(res);
uni.hideLoading();
}
});
}
0 个回复