admin管理员组文章数量:1389749
let url ='https://xxxx/image.jpg';
let blob = new Blob([url]);
let file = new File([blob], "filename", { type: "image/jpg" });
i am working on an angular project and would love to assign an image to file for upload. However the system cannot load the image after upload. any ideas??
let url ='https://xxxx/image.jpg';
let blob = new Blob([url]);
let file = new File([blob], "filename", { type: "image/jpg" });
i am working on an angular project and would love to assign an image to file for upload. However the system cannot load the image after upload. any ideas??
Share Improve this question asked Oct 4, 2022 at 8:29 appleapple 191 silver badge3 bronze badges1 Answer
Reset to default 5You can do this by using fallowings:
fetch('https://i.imgur./fHyEMsl.jpg')
.then((res) => res.blob())
.then((myBlob) => {debugger
const myFile = new File([myBlob], 'image.jpeg', {type: myBlob.type});
});
本文标签: javascriptConvert image (from url) to FileStack Overflow
版权声明:本文标题:javascript - Convert image (from url) to File - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744731928a2622096.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论