wx.chooseMedia({
count: remain,
mediaType: ['image'],
sourceType: ['album', 'camera'],
sizeType: ['compressed'],
success: async (res) => {
const files = res.tempFiles || [];
if (!files.length) return;
wx.showLoading({ title: '上传中...', mask: true });
try {
for (let i = 0; i < files.length; i += 1) {
if (this.data.attachmentFileIds.length >= this.data.maxFiles) break;
const file = files[i];
if (!file || !file.tempFilePath) continue;
const filename = this.buildImageUploadName(file, i);
const contentType = this.resolveImageContentType(filename);
try {
await this.uploadAttachmentByPath(
file.tempFilePath,
filename,
contentType,
Number(file.size) || 0,
false
);
} catch (err) {
console.error('反馈图片上传失败:', err);
}
}
} finally {
wx.hideLoading();
}
},
fail: (err) => {
console.error('选择图片失败:', err);
wx.showToast({ title: (err && err.errMsg) || '选择图片失败', icon: 'none' });
}
});
真机可以正常上传,但是在开发者工具中会报错
反馈图片上传失败: Error: readFile:fail http://tmp/2IKzHfoM9nrg2d7aa79b32c8270dc0733b24828732ae.jpg not found
at toUploadError (upload.js:57)
at _callee$ (upload.js:170)
at s (regeneratorRuntime.js?forceSync=true:1)
at Generator.<anonymous> (regeneratorRuntime.js?forceSync=true:1)
at Generator.throw (regeneratorRuntime.js?forceSync=true:1)
at asyncGeneratorStep (asyncToGenerator.js?forceSync=true:1)
at i (asyncToGenerator.js?forceSync=true:1)(env: Windows,mp,2.01.2510260; lib: 3.15.0)
我在开发者工具中打开这个临时路径,图片也是存在的
求大神解答

上传图片,为什么错误信息里边包含 readFile 呢?
用什么版本的开发者工具,试试i最新的稳定版的,看看效果。