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

本文标签: javascriptConvert image (from url) to FileStack Overflow