javascript判断文件是否存在(客户端、服务器端)
1,判断客户端文件
fso=new ActiveXObject("Scripting.FileSystemObject");
if(fso.FileExists(filespec))
s+=" exists.";
else
s+=" doesn't exist.";
alert(s);
2,判断服务器端(网络文件)
xmlhttp.open("GET",yourFileURL,false);
xmlhttp.send();
if(xmlhttp.readyState==4){
if(xmlhttp.status==200)s+=" exists."; //url存在
else if(xmlhttp.status==404)s+=" doesn't exist."; //url不存在
else s+="";//其他状态
}
alert(s);
备注:
<input style="width:100%" type="file" name="" id="" contentEditable="false">中,可以把contentEditable设置成false限制用户只能选择文件。
您可能感兴趣的文章:
js 判断客户端能否上网多种方法
javascript判断文件是否存在(客户端、服务器端)
实例详解php cookie与session会话基本用法
asp.net中Cookie同Session的关系
Asp.net中实现HtmlButton客户端控制网页提交实现
PHP 不得不提的 session 与 cookie
php在web开发中的处理过程是什么
VC写的ActiveX控件能不能被ASP.NET引用
php的cookie怎么使用
禁止客户端js缓存的方法控讨