熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

用JavaScript限制圖片上傳長寬

2013-11-15 11:49:59  來源: JSP教程 

  <html>
<head>
<title>Upload Image</title>
<meta httpequiv=ContentType content=text/html; charset=gb>
</head>
<body bgcolor=#FFFFFF text=#>
<form name=IUpload action=upfileasp method=post>
<p><input type=file name=picsrc size= onchange=picshowsrc=documentIUploadpicsrcvalue>
<input type=button value=上載 onclick=detect()></p></form>
<p><img name=picshow src=_//jpg title=圖像預覽></p>
</body>
</html>

  <SCRIPT LANGUAGE=JavaScript>
<!
function imgExceedSize(wh){
if(!documentIUploadpicsrcvalue==){
if(picshowwidth>w||picshowheight>h){
alert(圖像尺寸+picshowwidth+X+picshowheight+\\圖像尺寸過大!你只能上傳尺寸為 +w+×+h+的圖像請重新浏覽圖片!);
return true;
}else{
return false;
}
}else{
return true;
}
}

  function detect(){
var ok=imgExceedSize();
if(ok){
documentIUploadreset();
}else{
documentIUploadsubmit();
}
}

  //>
</SCRIPT>


From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19709.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.