Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded

Tags:

This is my Javascript code

function upload(){
var byteCharacters = atob($scope.image1.compressed.dataURL.replace(/^data:image\(png|jpg);base64,/,''));
var byteNumbers = new Array(byteCharacters.length);
         for (var i = 0; i < byteCharacters.length; i++) {
          byteNumbers[i] = byteCharacters.charCodeAt(i);
         }
var byteArray = new Uint8Array(byteNumbers);
 var blob = new Blob([ byteArray ], {
     type : undefined
   });

This is my HTML

<div class="form-group text-16px" style="margin-top: 20px !important;">
    <label>Choose Material Photo : </label>
    <div>
    <input id="materialImage" type="file" accept="image/*" image="image1" resize-max-height="800" resize-max-width="800" resize-quality="0.7" resize-type="image/jpg" file-model="file" name="materialImage" onChange="checkFile()" ng-image-compress/>
    <div id="choose-image-compresser">
      <div image="image1" result-image="myCompressedImage"></div>
      </div>
    <img ng-src="{{image1.compressed.dataURL}}" />
        <span id="image-size-error" style="color:red;" hidden=""><small>Image size is too large</small></span>
    </div>
</div>

I am getting error

Error: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded