I am trying to design a module in which I would like to show a preview of the image to the user before he uploads the image to database.
I have found a solution which works for Firefox but is not working for IE and Chrome...Can someone help me out.
Here is my code:-
function imageURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#replaceMe').attr('src', e.target.result)
.width(100)
.height(100);
}
reader.readAsDataURL(input.files[0]);
}
}
And I am calling this function on change event of the file input control:-
<input type="file" class="file" onchange="imageURL(this)" />
And also I have tried this url steps but it doesnt work for IE7 and 8 and Chrome.