无为清净楼资源网 Design By www.qnjia.com
判断客户端文件时,可以用
复制代码 代码如下:
var fso,s=filespec;   // filespec="C:/path/myfile.txt"
fso=new ActiveXObject("Scripting.FileSystemObject");
if(fso.FileExists(filespec))
s+=" exists.";
else
s+=" doesn't exist.";
alert(s);

判断服务器端(网络文件)时,可以用
复制代码 代码如下:
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
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限制用户只能选择文件,而不能随便输入.
标签:
判断文件是否存在,javascript

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com