0

After uploading 10-20 images (~2MB, one by one in the synchronous loop) IE throws an error during loading the image from base64 string. I have in my code something like this:

var reader = new FileReader();
reader.onload = function (e) {
  var img = new Image();
  img.onload = function () { console.log('onload'); /* some simple work with canvas */ };
  img.onerror = function () { console.log('onerror'); };
  img.src = e.target.result;
};
reader.readAsDataURL(file);

IE throws an error after some time and do not want to load more images. I have tried to use setTimeout but without success.

Any ideas why it happens?

1 Answer 1

1

Browsers can have some limitation on data URI size

Try the URL.createObjectURL instead

var src = URL.createObjectURL(file);
var img = new Image();
img.onload = function () { 
    /* some simple work with canvas */ };
    URL.revokeObjectURL(src); 
    console.log('onload');
img.onerror = function () { console.log('onerror'); };
img.src = src;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.