/文件上传/
uploadFile: function(imgUrl, imgPath) {
// 返回promise
return new Promise((resolve, reject) => {
pub.doShowLog('####request file start param:',{url:imgUrl,data:imgPath});
uni.uploadFile({
url: imgUrl, // 后端api接口
filePath: imgPath, // uni.chooseImage函数调用后获取的本地文件路劲
name: 'file', //后端通过'file'获取上传的文件对象
success: res => {
res.data = JSON.parse(res.data);
pub.doShowLog('####request file end success:',{url:imgUrl,data:res});
checkRstSuccess(res);
// 将结果抛出
resolve(res);
},
fail: function(err) {
pub.doShowLog('###end file fail reason:',{url:imgUrl,errorMsg:err},'error');
resolve(err);
},
});
});
},
1 个回复
咳
额。。抓错误代码啊。