2014-02-12 3 views
0

base64 문자열에서 이미지를로드하는 동안 10-20 개의 이미지 (동기 루프에 하나씩 ~ 2MB)를 업로드하면 IE에서 오류가 발생합니다. 내 코드에 다음과 같은 내용이 있습니다.IE10 - base64로 인코딩 된 이미지로드 오류

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는 일정 시간이 지나면 오류를 발생시키고 더 많은 이미지를로드하지 않습니다. setTimeout을 사용해 보았지만 성공하지 못했습니다.

왜 그런가?

답변

1

브라우저는

URL.createObjectURL 대신

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; 
을 시도 데이터 URI 크기에 약간의 제한이 있습니다
관련 문제