Skip to content Skip to sidebar Skip to footer

Error:failed To Execute 'atob' On 'window': The String To Be Decoded Is Not Correctly Encoded

This is my Javascript code function upload(){ var byteCharacters = atob($scope.image1.compressed.dataURL.replace(/^data:image\(png|jpg);base64,/,'')); var byteNumbers = new Array(b

Solution 1:

I got my problem. It should be helpful for another user for save the image and compress the image using javascript(AnguarJs).

I am flowing this link to compress the imageGithub

https://github.com/oukan/angular-image-compress

var imageData = $scope.image1.compressed.dataURL.toString();
var byteCharacters = atob(imageData.replace(/^data:image\/(png|jpeg|jpg);base64,/, ''));
var byteNumbers = newArray(byteCharacters.length);
for (var i = 0; i < byteCharacters.length; i++) {
  byteNumbers[i] = byteCharacters.charCodeAt(i);
}

var byteArray = newUint8Array(byteNumbers);
var blob = newBlob([ byteArray ], {
   type : undefined
});

Post a Comment for "Error:failed To Execute 'atob' On 'window': The String To Be Decoded Is Not Correctly Encoded"