javascript判断文件是否存在
1. 客户端
<script language="javascript"> function fileexist() { var sfso=new activexobject("scripting.filesystemobject"); var fpath="[the path of the file]"; if(sfso.fileexists(fpath)) { alert("exist"); } else { alert("doesn't exist"); } } </script>
2. 服务器端
<script language="javascript"> function fileexist() { var xmlhttp=new activexobject("microsoft.xmlhttp"); xmlhttp.open("get",fileurl,false); xmlhttp.send(); if(xmlhttp.readystate==4) { if(xmlhttp.status==200) alert("exist"); else if(xmlhttp.status==404) alert("doesn't exist"); else alert("don't know"); } } </script>
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
如对本文有疑问, 点击进行留言回复!!
网友评论