读写文件:
var f = fso.CreateTextFile("c:\\pexam\\"+name+".txt", true);
f.write(arr);
f.Close();
var ForReading=1;
var fso=new ActiveXObject("Scripting.FileSystemObject");
var f=fso.OpenTextFile(src,ForReading,true);
return(f.ReadAll());
判断文件是否存在:
if(fso.FileExists(path))
s+=" 文件存在.";
else
s+=" 文件不存在.";
服务器端的判断:
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET",yourFileURL,false);
xmlhttp.send();
if(xmlhttp.readyState==4){
if(xmlhttp.status==200)s+=" 存在."; //url存在
else if(xmlhttp.status==404)s+=" 不存在."; //url不存在
else s+="";//其他状态
}
alert(s);