Convert Data URI to File then append to FormData

后端 未结 14 2658
逝去的感伤
逝去的感伤 2020-11-21 07:14

I\'ve been trying to re-implement an HTML5 image uploader like the one on the Mozilla Hacks site, but that works with WebKit browsers. Part of the task is to extract an imag

14条回答
  •  Happy的楠姐
    2020-11-21 07:17

    The evolving standard looks to be canvas.toBlob() not canvas.getAsFile() as Mozilla hazarded to guess.

    I don't see any browser yet supporting it :(

    Thanks for this great thread!

    Also, anyone trying the accepted answer should be careful with BlobBuilder as I'm finding support to be limited (and namespaced):

        var bb;
        try {
            bb = new BlobBuilder();
        } catch(e) {
            try {
                bb = new WebKitBlobBuilder();
            } catch(e) {
                bb = new MozBlobBuilder();
            }
        }
    

    Were you using another library's polyfill for BlobBuilder?

提交回复
热议问题