欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

利用javascript判斷文件是否存在

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

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ǎng)絡文件)時,可以用
復制代碼 代碼如下:

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設置成false限制用戶只能選擇文件,而不能隨便輸入.

相關文章

最新評論