Error IE Java script Unable to get property value '0':
I have:
<img id="uploadedimage" alt="uploaded image" src="" width="250px" height="250px"/>
and have a div to display the image as soon as the user selects their image using this jQuery code:
$('#BusinessImage').change(function (ev) { var f = ev.target.files[0]; var fr = new FileReader(); var IsImage = false; // check the file is an image if (f.type.match('image.*')) { IsImage = true; } fr.onload = function (ev2) { if (IsImage) { $('#uploadedimage').attr('src', ev2.target.result); } }; if (IsImage) { fr.readAsDataURL(f); ValidFileUpload(); } else { InvalidFileUpload(); } });
Of course, this code works fine in any other browser except the Satans browser, Internet Explorer. I get this error:
Line: 108 Character: 13 Code: 0 Error Message: Unable to get value of the property '0': object is null or undefined
Does anyone know what causes this since it works great in FFX and Chrome.
thanks
". files" only work in browsers that support HTML5.
Files are supported in IE10, but for IE9 and earlier, you should use a different way to get the path .:
To check if files are supported:
if( ev.target.files ){ //supported console.log( ev.target.files[0] ); }else{ //.files not supported console.log( ev.target.value ); }