#Covert Data URI to Blob
Last active
April 13, 2016 15:10
-
-
Save taberh/4561156 to your computer and use it in GitHub Desktop.
Convert Data URI to Blob then can append FormData
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Convert Data URI to Blob | |
*/ | |
function dataURItoBlob(dataURI) { | |
var binary = atob(dataURI.splite(',')[1]); | |
var array = []; | |
var i = 0; | |
var l = binary.length; | |
for ( ; i < l; i++) { | |
array.push(binary.charCodeAt(i)); | |
} | |
return new Blob([new Uint8Array(array)], {type: 'image/jpeg'}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In 5th line it should be `splite' of course :)