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>
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
热门推荐
1 狗狗下楼训练
3 狗狗训练头盔
6 狗狗训练机构
7 训练狗狗步骤
9 狗狗能训练
10 狗狗基本动作训练方法
11 怎么训练狗狗叼饭盆
12 狗狗一岁了还能训练吗
13 训练狗狗的
14 宁波狗狗训练
15 训练狗狗拉屎
16 教狗狗训练
17 狗狗要怎么训练上厕所
18 狗狗靠的训练