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

网络编程 发布日期:2024/10/20 浏览次数:1

正在浏览:javascript判断文件是否存在实例代码

 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>

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

Windows上运行安卓你用过了吗
在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。