首页 > 开发 > JSP > 正文

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

2019-10-27 17:59:24
字体:
来源:转载
供稿:网友

 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>

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


注:相关教程知识阅读请移步到JSP教程频道。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表