嗨,我有图像选择器控件,用于在将图像上传到服务器后选择图像。而且我必须在同一页面中预览选定的图像,这在所有浏览器中都可以正常工作,但在 safari(我的版本 5.1.7)中却不行。这是我的代码。请提前帮助解决这个问题。
jQuery('#image').on('change', function ()
{
ext = jQuery(this).val().split('.').pop().toLowerCase();
if (jQuery.inArray(ext, ['gif', 'png', 'jpg', 'jpeg']) == -1) {
resetFormElement(jQuery(this));
window.alert('Not an image!');
}
else
{
file = jQuery('#image').prop("files")[0];
blobURL = window.URL.createObjectURL(file);
jQuery('#image_preview img').attr('src', blobURL);
jQuery('#image_preview').slideDown();
jQuery(this).slideUp();
}
});