---
title: "带有图片预览功能的上传表单"
author: "cfeers"
date: "2010-10-09T09:48:32Z"
tags: []
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2010-10-09T09:48:32Z"
id: 779199
url: "https://cfeers.iteye.com/blog/779199"
---

```
<html>       
<head>       
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">       
<title>带有图片预览功能的上传表单－－cnwebshow.com</title>       
<script>       
function viewmypic(mypic,imgfile) {        
if (imgfile.value){        
mypic.src=imgfile.value;        
mypic.style.display="";        
mypic.border=1;        
}        
}        
</script>       
</head>       
<body>       
<center>       
<form >       
<input name="imgfile" type="file" id="imgfile" size="40" onChange="viewmypic(showimg,this.form.imgfile);" />       
<br />       
</form>       
<img src="002.jpg" alt="图片浏览" name="showimg"  id="showimg" />       
<br />       
      
     
</center>       
</body>       
</html> 
```