-1
I have this script to give an image preview before the upload works perfectly in ie Chrome and firefox less in safari... anyone ever had problems with safari?? if anyone can give a hint... Acceptance
<head>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
function showimagepreview(input) {
if (input.files && input.files[0]) {
var filerdr = new FileReader();
filerdr.onload = function(e) {
$('#foto').attr('src', e.target.result);
$("#ft").fadeOut();
$("#foto").fadeIn(1000);
$("#label").fadeIn(1000);
}
filerdr.readAsDataURL(input.files[0]);
}
}
</script>
</head>
<body>
<form action="" method="Post" enctype="multipart/form-data" name="form" id="form">
<label id="label" style="display:none;">
<div id="dft1" class="img_preview">
<div class="img_prev">
<img id="foto" style="display:none;"/>
</div>
</div></label>
<input type="file" class="input_file" name="ft" id="ft" onchange="showimagepreview(this)"/>
</form>
</body>
What appears on your console if you do
console.log(typeof FileReader);
? I think Safari has problems with Filereader...– Sergio
@Sergio It is curious that the plugin page indicated by Tony has This plugin is unmaintained and Unsupported as File API is now widely supported (Almost 80% global support - http://caniuse.com/fileapi)... And the caniuse indicates that Safari is ok (?)...
– brasofilo
@brasofilo hence my question about what gives the console.log. I think only versions below 6 have this problem and Safari is good at forcing auto-updates.
– Sergio
i solved using the if(window.Filereader function)
– Jonatan