提交之前的图像预览在IE 9和Safari 5.x中不起作用 [英] Image Preview before submit doesn't work in IE 9 and Safari 5.x
本文介绍了提交之前的图像预览在IE 9和Safari 5.x中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在所选图片的客户端上进行图片预览,然后用户点击提交按钮。
I'm currently trying to make an image preview on the client side of selected image, before the user clicks on a submit button.
我发现这个方法在这里在论坛:
I've found this approach here in the forum:
function selectedPhotoText(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#imagePreview')
.attr('src', e.target.result)
.width(240)
.height(149);
};
reader.readAsDataURL(input.files[0]);
}
else {
$('#imagePreview').attr('src', "../../Images/blqblq.jpg");
}
}
<img id="imagePreview" class="img-border" src="../../Images/blqblq.jpg" alt="Selected Image"/>
和文件上传控制:
and the file upload control:
<asp:FileUpload ID="uploadPhotoDialog" onchange="selectedPhotoText(this)" runat="server"/>
这种方法在Chrome,Firefox和Opera中运行良好。是否有任何IE和Safari的变通办法?
This approach works fine in Chrome, Firefox and Opera. Is there any workarounds for IE and Safari?
提前致谢!
Thanks in advance!
推荐答案
5.XX和IE到9.xx的Safari不支持FileReader。
看这个。
http://caniuse.com/filereader
Safari to 5.X.X and IE to 9.x.x doesnt support FileReader. Look this. http://caniuse.com/filereader
这篇关于提交之前的图像预览在IE 9和Safari 5.x中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文