468,773 Members | 2,421 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,773 developers. It's quick & easy.

no client-side code to check if a file path exists?

<input type="file" size=50"> will produce the browse button
and browse text box.

The user can either select the file from browse button,
or enter a path in browse text box manually. My question is if
there are any client-side code to check if the path exists
in this case? My understanding is that no client-side
solution to this problem.

please advise. thanks!!
Jul 23 '05 #1
3 8330
Matt wrote:
<input type="file" size=50"> will produce the browse button
and browse text box.

The user can either select the file from browse button,
or enter a path in browse text box manually. My question is if
there are any client-side code to check if the path exists
in this case? My understanding is that no client-side
solution to this problem.


Your understanding is correct.

If they type it in the browse box though, and its an invalid path, then
the OS/browser won't allow the browse window to be closed. If they type
it into the file input box though, it won't respond until it attempts to
upload the file. And then, the browser/OS will notify the user. So what
you are trying to do is duplicate functionality that is already built-in
to the browser/OS

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #2
"Matt" <jr********@hotmail.com> wrote in message
news:ba**************************@posting.google.c om...
<input type="file" size=50"> will produce the browse button
and browse text box.

The user can either select the file from browse button,
or enter a path in browse text box manually. My question is if
there are any client-side code to check if the path exists
in this case? My understanding is that no client-side
solution to this problem.

please advise. thanks!!


This does what (I think) you want but it issues a security warning.

<html>
<head>
<title>typefile.htm</title>
<script type="text/javascript">
function typefile() {
var form = document.forms[0];
var file = form.what.value;
var fold = file.substr(0,file.lastIndexOf("\\"));
window.status = file + " : " + fold;
var oFSO = new ActiveXObject("Scripting.FileSystemObject")
if (!oFSO.FolderExists(fold)) {
alert("Folder does not exist!");
} else if (!oFSO.FileExists(file)) {
alert("File does not exist!");
}
}
</script>
</head>
<body>
<form>
<input type="file" name="what" size=50" onchange="typefile()">
</form>
</body>
</html>
Jul 23 '05 #3
[snip]

Typo!

<input type="file" name="what" size="50" onchange="typefile()">
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Michael Rybak | last post: by
2 posts views Thread by Raquel | last post: by
4 posts views Thread by Yasaswi Pulavarti | last post: by
2 posts views Thread by Rhino | last post: by
reply views Thread by netgeni59 | last post: by
reply views Thread by Russ | last post: by
2 posts views Thread by Johan | last post: by
2 posts views Thread by Frank Swarbrick | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.