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

页面实现上传前预览

时间:2016-09-26 17:52:51      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html>
<%@ page language="java" pageEncoding="utf-8"%>
<html>
<head>
<title>MyHtml.html</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<script src="jquery.js" type="text/javascript"></script>
</head>

<body>
<form action="./test" method="get" enctype ="multipart/form-data">
<input type="text" name="name" value=""/><br/>
<input type="file" id="path" name="file" />
<fieldset style="width:80px;height:80px">
<legend>预览</legend>
<img id="imge" width="50px" height="50px" style="visibility:hidden" />
</fieldset>
<input type="submit" value="submit"/>
</form>
</body>
<script type="text/javascript">
$("#path").change(function(e){
var reader = new FileReader();
var file = this.files[0];
reader.onloadstart = function (e) {};
reader.onprogress = function (e) {};
reader.onabort = function (e) {};
reader.onerror = function (e) {};
reader.onload = function (e) {
$("#imge").attr("style","visibility:visible");
$("#imge").attr("src", e.target.result);
};

reader.readAsDataURL(file);
});
</script>
</html>

页面实现上传前预览

标签:

原文地址:http://www.cnblogs.com/wbjgogogo/p/5909866.html

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