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

let url ='https:xxxximage.jpg';let blob = new Blob([url]);let file = new File([blob], &q

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744731928a4590515.html

相关推荐

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

    let url ='https:xxxximage.jpg';let blob = new Blob([url]);let file = new File([blob], &q

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信