經""" 版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://copyzhu.blogbus.com/logs/7730291.html """的提示。
我要把他的範例修改如下。但還是有一個問題未能克服,那就是 javascript 在抓 input 標籤的 value 時,居然不包含目錄。這情
況得再找找如何處理。
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8"/>
<title>图片上传</title>
<script type="text/javascript" language="javascript">
function viewmypic(mypic, imgfile)
{
if (imgfile.value)
{
mypic.src='file:///home/hoamon/'+imgfile.value; //你把
file:///home/hoamon/ 換成你上傳照片的目錄
mypic.style.display="";
mypic.border=1;
}
}
</script>
</head>
<body>
<center>
<form runat="server" id="Form1" >
<input name="imgfile" type="file" value='' id="imgfile" size="40"
onchange="viewmypic(showimg, this.form.imgfile);" />
<br />
</form>
<img name="showimg" id="showimg" src=""
style="display:none;cursor:hand;width:60px;height:60px" alt="缩略图预览" />
<!--讓圖在本機端即能顯示縮圖的重點,就在於 img 標籤內 src 屬性要能設成 file:///xxx/yyy/your_pic.png
-->
<br />
<div style="display:none">
</div>
</center>
</body>
</html>