利用javascript判断文件是否存在
2013-12-31 00:00
585 查看
判断客户端文件时,可以用
判断服务器端(网络文件)时,可以用
可以<input style="width:100%" type="file" name="" id="" contentEditable="false" >把contentEditable设置成false限制用户只能选择文件,而不能随便输入.
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判断文件是否存在
- 利用javascript判断文件是否存在
- JavaScript下利用fso判断文件是否存在的代码
- JavaScript下利用fso判断文件是否存在的代码
- javascript js 判断文件是否存在
- javascript判断文件是否存在
- javascript判断文件是否存在
- Javascript判断文件是否存在(客户端/服务器端)
- JavaScript 判断文件是否存在
- php下利用curl判断远程文件是否存在的实现代码
- Javascript判断文件是否存在(客户端/服务器端)
- javascript判断文件是否存在
- 请问怎么用javascript判断一个文件是否存在?
- 利用JS判断图片,文件是否存在的几种方法
- javascript判断文件是否存在实例代码
- javascript 判断文件是否存在 整理
- javascript判断文件是否存在
- MFC判断某路径下的目标文件是否存在
- Linux shell判断文件是否存在