Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // http://stackoverflow.com/questions/6150289/how-to-convert-image-into-base64-string-using-javascript
- function imgToDataUrl(url) {
- var deferred = $q.defer();
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'blob';
- xhr.onload = function() {
- var reader = new FileReader();
- reader.onloadend = function() {
- deferred.resolve(reader.result);
- }
- reader.readAsDataURL(xhr.response);
- };
- xhr.open('GET', url);
- xhr.send();
- return deferred.promise;
- }
Advertisement
Add Comment
Please, Sign In to add comment