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>
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!