亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

利用javascript判斷文件是否存在

 更新時(shí)間:2013年12月31日 09:46:23   作者:  
本篇文章主要介紹了利用javascript判斷文件是否存在的方法。需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助
判斷客戶端文件時(shí),可以用
復(fù)制代碼 代碼如下:

var fso,s=filespec;   // filespec="C:/path/myfile.txt"
fso=new ActiveXObject("Scripting.FileSystemObject");
if(fso.FileExists(filespec))
s+=" exists.";
else
s+=" doesn't exist.";
alert(s);

判斷服務(wù)器端(網(wǎng)絡(luò)文件)時(shí),可以用
復(fù)制代碼 代碼如下:

var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET",yourFileURL,false);
xmlhttp.send();
if(xmlhttp.readyState==4){  
if(xmlhttp.status==200)s+=" exists."; //url存在  
else if(xmlhttp.status==404)s+=" doesn't exist."; //url不存在  
else s+="";//其他狀態(tài)  
}
alert(s);

可以<input style="width:100%" type="file" name="" id=""   contentEditable="false" >把contentEditable設(shè)置成false限制用戶只能選擇文件,而不能隨便輸入.

相關(guān)文章

最新評(píng)論