小编use*_*468的帖子

带预览和删除的图像上传

有关于以下脚本的跟随问题和需要答案,这些脚本将在上传之前预览照片.该脚本来自http://jsbin.com/uboqu3/edit#javascript,html

1)该脚本适用于Firefox,对IE没有好处.如何让它适用于IE?

2)没有删除照片的方法.需要像预览照片上安装的小图像"X",单击此"X"将删除照片.谁能提供这个解决方案?

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
function readURL(input) {
    if (input.files && input.files[0]) {
        var reader = new FileReader();

        reader.onload = function (e) {
            $('#img_prev')
            .attr('src', e.target.result)
            .height(200);
        };

        reader.readAsDataURL(input.files[0]);
    }
}
</script>

<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
</style>
</head>
<body>
<input type='file' onchange="readURL(this);" />
<img id="img_prev" src="#" alt="your image" />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

javascript upload jquery

3
推荐指数
2
解决办法
2万
查看次数

标签 统计

javascript ×1

jquery ×1

upload ×1