日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

file control

發(fā)布時間:2025/3/13 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 file control 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

看來你是想驗證是否為空,不是要檢測大小?

<form?name="fr"?action="up.asp"?method="post"?enctype="multipart/form-data"?onsubmit="return?chk()">?
<input?type="file"?name="file"?size="30">?
<input?type="submit"?name="submit"?value="上傳">?
<script?language="javascript">?
function?chk()?
{?
var?s
=fr.file.value;?
if(fr.file.value=="")?
{?
alert(
"請輸入圖片地址!");?
fr.file.focus();?
return?false;?
}?
s
=s.substr(s.lastIndexOf(".")+1,3);?
if(s!="gif"&&s!="jpg")?
{?
alert(
"請選擇正確的圖片格式!")?
return?false;?
}?
}?
</script>?
--------------------------------------------------------------------
<input???id=inp???type="file">???
??
<button???onclick="ys()">Test</button>???
??
<script>???
??var???img
=null;???
??function???ys()???
??{???
??
if(img)img.removeNode(true);???
??img
=document.createElement("img");???
??img.style.position
="absolute";???
??img.style.visibility
="hidden";???
??img.attachEvent(
"onreadystatechange",orsc);???
??img.attachEvent(
"onerror",oe);???
??document.body.insertAdjacentElement(
"beforeend",img);???
??img.src
=inp.value;???
??}???
??function???oe()???
??{???
??alert(
"cant???load???img");???
??}???
??function???orsc()???
??{???
??
if(img.readyState!="complete")return???false;???
??alert(
"圖片大小:"+img.offsetWidth+"X"+img.offsetHeight);???
??alert(
"圖片尺寸:"+img.fileSize);???
??}???
??
</script>
------------------------------------------------------------------------------------
<input???name="file1"???type="file"???class="style1"?????size="18"???onpropertychange="document.all.testImage1.src=this.value">???
??????????????????????
<font???size="2"></font>?????
??????????????????????
<input???name="ow1"???type="text"???class="style1"???id="ow1"???style="background-color:#efefef;"???size="3"?????readonly>???
??????????????????????
<font???size="2">px???高</font>?????
??????????????????????
<input???name="oh1"???type="text"???class="style1"???id="oh1"???style="background-color:#efefef;"???size="3"?????readonly>???
??????????????????????
<SCRIPT???LANGUAGE="JavaScript">???
??
<!--???
??var???upStr
="<INPUT?????TYPE=\"file\"???NAME=\"file1\"???onpropertychange=\"document.all.testImage1.src=this.value\"???>";???
??
//-->???
??</SCRIPT>???
??????????????????
<input???name=testit1???type=hidden???value="">???
??????????????????
<div???id="Layer1"???style="position:absolute;???left:232px;???top:204px;???width:55px;???height:49px;???z-index:1">?????
??????????????????????
<img???src="syspic/upset0.gif"???name=testImage1???
??onload
="???
??{???
??var???objs
=document.all???
??
if???(objs.testit1.value!='')???
??{???
??objs.ow1.value
=this.width;???
??objs.oh1.value
=this.height;???
??}???
??
else???
??{???
??objs.testit1.value
=1;???
??}???
??}
"???
??onerror="{alert('選擇的圖像類型錯誤或者目標不存在');window.upfile.innerHTML=upStr;}"?????
??
></div>

轉載于:https://www.cnblogs.com/hq2008/archive/2007/08/09/849419.html

總結

以上是生活随笔為你收集整理的file control的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。