您的位置:首页 > Web前端 > HTML5

HTML5实现图片选择并预览

2015-12-18 14:20 537 查看
<%@ 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>


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: