gpt4 book ai didi

angularjs - 将base64数据url转换为angularjs中的图像文件

转载 作者:行者123 更新时间:2023-12-02 19:32:24 25 4
gpt4 key购买 nike

我的 angularJs Controller 中有 base64 数据 URL,我需要其中的图像文件,以便我可以通过 ajax 将其作为多部分数据发送到服务器?

我正在寻找类似 angularjs 中的文件编写器的东西。有人可以帮我吗?

最佳答案

您可以从 Base64 数据生成 blob。

var imageBase64 = "image base64 data";
var blob = new Blob([imageBase64], {type: 'image/png'});

从这个 blob 中,您可以生成文件对象。

var file = new File([blob], 'imageFileName.png');

您可以使用此文件对象并使用多部分数据将其发布到服务器。

关于angularjs - 将base64数据url转换为angularjs中的图像文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31878639/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com