I'm using javascript FileReader class to preview the image prior to uploading it to the server. Everything seems to work fine with Firefox and Chrome but it does not seem to work with IE for some reason.
Below is my code for it. (This is for Cakephp framework)
Is there a way we can fix this so it works in IE too?
<script type="text/javascript">
function imageBack(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#uploadBackImage').attr('src', e.target.result);
$('#cardbackImagePath').attr('value',e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
</script>
<input type="file" name="data[Card][uploadBack]" class="file" onchange="imageBack(this);" width="240" height="150" id="CardUploadBack">