Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking if a file exists

Status
Not open for further replies.

SandorC

MIS
Aug 26, 2001
39
BR
Hi to all!
How can I check if a file exists in the default directory,
using javascript? (want to make sure the .html exist to avoid 404 error)
Thanx
Sandor
 
The File Object in Javascript is only for Server Side JavaScript. You cannot use the File object for Client side File validation. It is not possible.
 
Hi pazhanikanthan.
Thanks for answering.
What I am trying to do is, type a file name on a previous input, then check the existence of the file.
If exists, open it with windows.location.href=(...) and if not, send an "invalid password" alert. (kind of password checking)
There is some other way to do it?
Regards.
Sandor
 
Hi,
I didnt get ur problem clearly. But as far as I know we cannot touch a Client's File Information in JavaScript. Java is Secure. Even VB Script will not work out.
If you want more infor contact me at pazhanikanthan@yahoo.com
Thanks and regards,
Pazhanikanthan. P
 
Hi pazhanikanthan!
I sent you an e-mail last week and got no answer, si I postin it below...
- - - - - -
What I want to do is a sort of password checking to access some restricted area in a site (using geocities). I have an input field (see example) and the user types a password.
The password is the name of the next HTML page. If is correct, it opens the page (already working), if not, displays a "page not found" message.
I want to check if the HTML page exists to send an alert (Invalid Password) to avoid the "page not found error". Piece of the page follows.

<html>
<body leftmargin=30 topmargin=30>
<form action=&quot;javascript:OpenWin()&quot; method=get name=&quot;F1&quot;>
<B>Type the Password :</B>&nbsp<input name=&quot;P1&quot; type=password> &nbsp;
<script language=&quot;javascript&quot;>function OpenWin()
{ window.location.href = document.F1.P1.value+&quot;.htm&quot;) }</script>
<INPUT TYPE=&quot;submit&quot; VALUE=&quot; GO &quot;>
</form>
</body>
</html>
- - - - - -

Thanks and Regards
Sandor

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top