有什么方法可以在JavaScript中获取任何远程文件的base64编码字符串?
我有一个图像网址:
url = "https://wallpaperaccess.com/full/3678503.png";
有没有办法在 JavaScript 中获取该远程文件的 Base64 编码字符串?
I have an image url:
url = "https://wallpaperaccess.com/full/3678503.png";
Is there any way to get base64 encoded string of that remote file in javascript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在这个代码上找到了实现这一目标的代码。唯一的问题是您会遇到CORS问题。如果您是托管图像的页面的所有者,则可以配置以避免CORS。
在这里找到来源的链接: https://stackoverflow.com/a/a/20285053/14807111
I found on SO this codesnipet to achieve this. The only problem would be that you will run into CORS Problem. If you are the owner of the page which hosted the image you can configure up to avoid CORS.
And here the Link where i found the source: https://stackoverflow.com/a/20285053/14807111