方法一:
//判断文件是否存在
function IsExstsFile(filespec) {
var fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FileExists(filespec))
return true;
else
return false;
}
function IsExstsFile(filespec) {
var fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FileExists(filespec))
return true;
else
return false;
}
方法二: (加载ActiveXobject容易出现权限错误!)
function test() {
var fileURL = ""; //文件路径(相对路径)var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");xmlhttp.open("GET",fileURL,false);xmlhttp.send()();if(xmlhttp.readyState==4){ if(xmlhttp.status==200) return true; //存在else if(xmlhttp.status==404) return false; //不存在 else alert("Error"); //报错//其他状态 } }