Reputation: 21
I have this javascript function which shows a preview after user picked an image. My problem is that it's not working on IE and I do not figure out why.
No error, but input.files is null.
The JavaScript
function showimagepreview(input, previewId) {
if (input.files && input.files[0]) {
var filerdr = new FileReader();
filerdr.onload = function (e) {
$('#' + previewId).attr('src', e.target.result);
}
filerdr.readAsDataURL(input.files[0]);
}
}
this is my HTML code
<div class="photo" id="photo-1">
<input type="file" class="upload-file" name="Photos[1]" onchange="showimagepreview(this, 'photosPreview1')" />
<img id="photosPreview1" class="PhotoPreview" />
</div>
Upvotes: 1
Views: 7108
Reputation: 101
As explain previously IE 8 Doesn't support FileReader API http://caniuse.com/#feat=filereader
But you can use a polyfill ! Moxie can solve your problem. https://github.com/moxiecode/moxie
Upvotes: 1