Home >Web Front-end >JS Tutorial >Code to use fso to determine whether a file exists under JavaScript_javascript skills

Code to use fso to determine whether a file exists under JavaScript_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:14:001208browse
Copy code The code is as follows:

function ReportFileStatus(filespec)
{
var fso, s = filespec;
fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FileExists(filespec))
s = " exists.";
else
s = " doesn't exist.";
return(s);
}

Using the client's FileSystemObject object
Example:
Copy code The code is as follows:

function check()
{
var fso;
fso = new ActiveXObject(" Scripting.FileSystemObject");
if( fso.FileExists("c:\testfile.txt"))
{
alert("Exists!");
}
else
{
alert("not Exists!");
}
} 
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn