posts - 35,  comments - 6,  trackbacks - 0
 <span id="preview" style="display: none;" > </span>
      <br>
      
        图&nbsp;&nbsp;&nbsp;&nbsp;片:
       
       <input type="file" name="picFile" style="width:80% ;"
         onchange="javascript:previewImage(this,'preview',120);" />
      <br>

 function previewImage(picFile,picViewSpanName,picWidth)
{
  var previewSpan=document.getElementById(picViewSpanName);
if(picFile.value=='')
{
 return ;
}
else
{
 previewSpan.style.display="block";
}
if(picWidth=='')
{
  picWidth=120;
}
var fileext=picFile.value.substring(picFile.value.lastIndexOf("."),picFile.value.length)
fileext=fileext.toLowerCase()   
if ((fileext!='.jpg')&&(fileext!='.jpeg')&&(fileext!='.png')&&(fileext!='.bmp'))
{

picFile.focus();
}
else
{
//alert(''+document.form1.picFile.value
    document.getElementById(picViewSpanName).innerHTML="<table border='1'><tr><td><img src='"+picFile.value+"' width='"+picWidth+"' style='border:6px double #ccc'><br>ÉÏ´«Í¼Æ¬Ô¤ÀÀ</td></tr></table>"

}
posted on 2007-04-17 14:18 NG 阅读(359) 评论(1)  编辑  收藏


FeedBack:
# re: 图片上传浏览
2007-05-10 07:39 | NG
文件上传表单定义时是要加上 enctype="multipart/form-data" 这个属性的。
  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航:
 
<2007年4月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

常用链接

留言簿(1)

随笔档案(35)

文章分类(5)

文章档案(2)

新闻档案(5)

java link

搜索

  •  

最新评论

阅读排行榜

评论排行榜