Convert blob to image file

后端 未结 2 1051
春和景丽
春和景丽 2021-01-15 06:39

I am trying to convert an image file captured from an input type=file element without success. Below is my javascript code

        var img = document.getEle         


        
2条回答
  •  感情败类
    2021-01-15 06:49

    You can't manipulate hard drive directly from the browser. What you can do though is create a link that can be downloaded.

    To do this change your var newfile = new File([theBlob], "c:files/myfile.jpg"); into:

    const a = document.createElement('a');
    a.setAttribute('download', "some image name");
    a.setAttribute('href', theBlob);
    
    a.click();
    

提交回复
热议问题