ITeye博客

HTML实现上传表单有图片预览

qxmcool · 2010-01-27 10:23 · 其他 · Web前端 · Markdown

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script> 
	function viewmypic(mypic,imgfile) { 
	if (imgfile.value){ 
		mypic.src=imgfile.value; 
		mypic.style.display=""; 
		mypic.border=1; 
} 
} 
</script> 
<title>无标题文档</title>
</head>

<body>

<center> 
<form > 
<input name="imgfile" type="file" id="imgfile" size="40" onchange="viewmypic(showimg,this.form.imgfile);" /> 
<br /> 
</form> 
<img name="showimg" id="showimg" src="" style="display:none;" alt="预览图片" /> 
<br /> 
</div> 
<div style="display:none"> 
</div> 
</center> 

</body>
</html>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。