码迷,mamicode.com
首页 > Web开发 > 详细

HTML5实现图片选择并预览

时间:2015-12-18 14:43:07      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script src="jquery-1.11.2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $(function () {
                $("#fileupload").change(function () {
                    var reader = new FileReader();

                    reader.onload = function (e) {
                        $("#img1").attr("src",e.target.result);
                    }

                    reader.readAsDataURL($(this)[0].files[0]);
                })

            });
        })
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <input id="fileupload" type="file" />
    <img id="img1" style="width:150px; height:90px;" />
    </form>
</body>
</html>

技术分享

HTML5实现图片选择并预览

标签:

原文地址:http://www.cnblogs.com/franky2015/p/5056941.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!