这么复杂呀·没人回复个!!!
上传提示fail createUploadTask:fail file not found?相同的上传代码,为什么使用we-cropper头像截图错误提示找不到文件? const uploadFile = async (url, { name = "file", filePath, formData = { type: "picture", uid: wx.getStorageSync('userInfo') ? wx.getStorageSync('userInfo').uid:"" }, } = {}) => { console.log(filePath)// url = formatUrl(url) try { let res = await wx.pro.uploadFile({ url, filePath: filePath, name, formData }) console.log(name) console.log(filePath) console.log(url) console.log(formData) console.log(res) //网络请求错误 if (res.statusCode != 200) { throw res; } let data = JSON.parse(res.data) //服务器提示错误 if (data.code != 0) { throw res; } return data.data } catch (e) { console.log(name) console.log(filePath) console.log(url) console.log(formData) console.log(e) util.hideAll() if (e.statusCode!=200){ util.networkError(e.statusCode) }else{ let data = JSON.parse(e.data) let { code, msg } = data if (code == -2) { let { confirm } = await wx.pro.showModal({ title: '权限不足', content: msg, confirmText: "去开通" }) if (confirm) util.goUrl('/pages/ucenter/member/member'); }else{ util.showFail(msg) } } return await Promise.reject(e); } } [图片] 非we-cropper上传的log: q.js? [sm]:218 http://tmp/sdn5KxOt3CMo9b3902b3b62cbf33d9c05132d51cfa9c.png q.js? [sm]:222 file q.js? [sm]:223 http://tmp/sdn5KxOt3CMo9b3902b3b62cbf33d9c05132d51cfa9c.png q.js? [sm]:224 https://API.XXXXXX.COM/API.php?i=1 q.js? [sm]:225 {type: "picture", uid: 9} 使用we-cropper上传的log: q.js? [sm]:218 http://tmp/R7LDSTKDpB5Z748f7e39d6a2252cf16409ba0f050069.jpg q.js? [sm]:235 file q.js? [sm]:236 http://tmp/R7LDSTKDpB5Z748f7e39d6a2252cf16409ba0f050069.jpg q.js? [sm]:237 https://API.XXXXXX.COM/API.php?i=1 q.js? [sm]:238 {type: "picture", uid: 4} q.js? [sm]:239 {errMsg: "uploadFile:fail createUploadTask:fail file not found"}
2022-05-01