当前位置:主页 > 查看内容

javascript判断文件是否存在实例代码

发布时间:2021-05-05 00:00| 位朋友查看

简介: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 { aler……

 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>

 感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!


本文转载自网络,原文链接:https://m.jb51.net/article/102096.htm
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!
上一篇:BootStrap在jsp中的使用 下一篇:没有了

推荐图文

  • 周排行
  • 月排行
  • 总排行

随机推荐