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?
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.