In one of my web application I have to implement a image upload. But I need to show the image(s) before upload in my browser . I found the following javascript code and pretty working in all browsers except Safari, IE.
function handleFiles(files) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
var imageType = /image.*/;
if (!file.type.match(imageType)) {
$('.img_error_con').html("Invalid image file.");
$('.img_error_con').fadeIn(200);
return false;
continue;
}
var img=document.getElementById('fake_img');
img.src = file;
img.onload = function() {
};
var reader = new FileReader();
reader.onload = (function(aImg) {
return function(e) {
aImg.src = e.target.result;
};
})(img);
reader.readAsDataURL(file);
}
}
Please help me to solve the issue in Safari . or any HTML5 method for doing this job ?
Please help
Thanks in advance
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…