file control
生活随笔
收集整理的這篇文章主要介紹了
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的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: VC++连MySQL小记
- 下一篇: 存储过程,触发器,事务和锁