最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Convert image (from url) to File - Stack Overflow

programmeradmin1浏览0评论
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 badges
Add a ment  | 

1 Answer 1

Reset to default 5

You 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});
    });

发布评论

评论列表(0)

  1. 暂无评论