程序探讨
微信 小程序 头像
微信小程序使用open-type="chooseAvatar"拉取头像在ios下提示600005:uploadFile:fail url scheme is invalid错误
微信小程序使用open-type="chooseAvatar"拉取头像更新用户头像,在安卓下没问题,在ios下提示【"errno":600005,"errMsg":"uploadFile:fail url scheme is invalid】错误,如何处理?
2024-12-11 16:32  0条评论
1 个回复
CMSYOU ,CMS企业网站定制专家
有人说是权限问题,需要检查小程序是否有读取文件的权限“permission": {"scope.writePhotosAlbum": true},经过测试跟这个无关,实际上scope.writePhotosAlbum授权是保存图片到相册,跟读取没关系。

经过CMSYOU排查,问题在于ios下的临时文件网址不能读取,只能先转为base64编码,然后再上传。
具体方法:
{{{
let tempFilePath = e.detail.avatarUrl;
let imgbase64 = 'data:image/png;base64,' + wx.getFileSystemManager().readFileSync(tempFilePath, "base64");
uni.uploadFile({
url: 'https://www.cmsyou.com/index.php?m=attachment&c=image&a=init',
filePath: tempFilePath,
name: 'avatar_file',
formData: {
'type': 'image',
'avatar': imgbase64
},
success: (_data) => {
//上传成功
},
complete(res) {
//console.log(res)
}
});
}}}
测试ios通过。
2024-12-11 16:38

要查看所有问题和参与问题请先 登录

Copyright © 2026 CMSYOU 互动社区 粤ICP备10060801号-3 All Rights Reserved.