javascript js 判断文件是否存在
2009-03-12 18:10
441 查看
判断客户端文件时,可以用
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限制用户只能选择文件,而不能随便输入.
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 判断文件是否存在 整理
- Node.js 中fs.access() 判断文件和目录是否存在;
- JavaScript下利用fso判断文件是否存在的代码
- JavaScript下利用fso判断文件是否存在的代码
- 利用javascript判断文件是否存在
- [JavaScript]判断JS中的函数(方法)是否存在
- JS基础篇--如何用JavaScript判断dom是否有存在某class的值?
- JS中判断JSON数据是否存在某字段的方法 JavaScript中判断json中是否有某个字段
- javascript判断文件是否存在
- JS判断window本地路径地址和网络url地址文件时是否存在
- javascript判断文件是否存在
- 利用javascript判断文件是否存在
- javascript判断文件是否存在实例代码
- js 判断文件是否存在
- javascript判断文件是否存在
- 利用javascript判断文件是否存在
- js判断服务器上的文件是否存在
- js判断服务器端文件是否存在
- JS判断文件是否存在
- 请问怎么用javascript判断一个文件是否存在?