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

M

Matt

<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!!
 
R

Randy Webb

Matt said:
<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
 
M

McKirahan

Matt said:
<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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top