Download data url file

前端 未结 9 1587
猫巷女王i
猫巷女王i 2020-11-22 09:34

I\'m playing with the idea of making a completely JavaScript-based zip/unzip utility that anyone can access from a browser. They can just drag their zip directly into the br

9条回答
  •  臣服心动
    2020-11-22 09:57

    For anyone having issues in IE:

    Please upvote the answer here by Yetti: saving canvas locally in IE

    dataURItoBlob = function(dataURI) {
        var binary = atob(dataURI.split(',')[1]);
        var array = [];
        for(var i = 0; i < binary.length; i++) {
            array.push(binary.charCodeAt(i));
        }
        return new Blob([new Uint8Array(array)], {type: 'image/png'});
    }
    
    var blob = dataURItoBlob(uri);
    window.navigator.msSaveOrOpenBlob(blob, "my-image.png");
    

提交回复
热议问题