javascript判断文件是否存在实例代码
javascript判断文件是否存在
1.客户端
<scriptlanguage="javascript">
functionFileExist()
{
varsfso=newActiveXObject("Scripting.FileSystemObject");
varfPath="[Thepathofthefile]";
if(sfso.FileExists(fPath))
{
alert("Exist");
}
else
{
alert("Doesn'texist");
}
}
</script>
2.服务器端
<scriptlanguage="javascript">
functionFileExist()
{
varxmlhttp=newActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET",FileURL,false);
xmlhttp.send();
if(xmlhttp.readyState==4)
{
if(xmlhttp.status==200)alert("Exist");
elseif(xmlhttp.status==404)alert("Doesn'texist");
elsealert("Don'tknow");
}
}
</script>
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短