在我的iOS设备上调用wx.uploadFile接口报以下错误:
"MiniProgramError\nr.replace is not a function. (In 'r.replace(/\;([^\s\;]*?(?=\=))/gi,",$1")', 'r.replace' is undefined)\nTypeError: r.replace is not a function. (In 'r.replace(/\;([^\s\;]*?(?=\=))/gi,",$1")', 'r.replace' is undefined)\nat replace (miniprogram_npm/weapp-cookie/index.js:2414:45)\nat (WAServiceMainContext.js:1:2473449)\nat YX (WAServiceMainContext.js:1:2258626)\nat success (WAServiceMainContext.js:1:2260733)\nat <api uploadFile success callback function>\nat c (WAServiceMainContext.js:1:801289)\nat (WAServiceMainContext.js:1:616788)\nat <NetworkUpload1success callback function>\nat (WAServiceMainContext.js:1:746326)\nat forEach (native code)\nat emit (WAServiceMainContext.js:1:746249)\nat W (WAServiceMainContext.js:1:617843)\nat (WAServiceMainContext.js:1:619289)\nat (WAServiceMainContext.js:1:781469)\nat emit (WAServiceMainContext.js:1:81766)\nat (WAServiceMainContext.js:1:84248)\nat emit (WAServiceMainContext.js:1:81389)\nat subscribeHandler (WAServiceMainContext.js:1:83949)\nglobal code"
设备:iPhone Xs 14.8
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
麻烦复现问题的时候,在手机微信那里上传下日志: 我->设置->帮助与反馈右上角有个上报日志的入口,麻烦提供一下微信号,时间点(具体到分钟)
微信版本号:8.0.26
系统版本号:14.8
微信号:zijuntang
复现时间:2022年8月19日17:22
代码片段没弄好,问题就是wx.uploadFile 这个函数就报错
我也遇到这个问题了,卡住解决不了了,报同样的错,安卓和模拟器都是好的,感觉和uploadFile函数的filePath参数是wxfile://tmp_xxxx.jpg 本地文件路径有关系。
楼主最终咋解决的?求助哈,求分享出来吧@子君
临时解决方案 try catch 包一下 在uni.uploadFile 的 complete回调中做处理 因为我这上传接口是调用成功的
try {
uni.uploadFile({
url: ``,
filePath: item,
name: "file",
header: {
access_token: token,
},
success: (data) => {
console.info("-----uploadFilesuccess----", data)
},
fail: (err) => {
console.info("-----fail----", err)
this.Toast("上传图片失败");
},
complete: (data) => {
if (data.errMsg === "uploadFile:ok") {
const file = JSON.parse(data.data);
this.fileList = [file.data];
}
console.info("-----complete----", data);
}
});
} catch (e) {
console.info('try catch', e);
}
wx.downloadFile在真机测试也报同样的错误
补充信息:
1、合法域名已经配置,证书都检查过,都正常
2、小程序是好好运行了好几个月没有更新的情况下,突然出现了iOS设备无法上传图片的问题,查看后线上以上的错误信息