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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I check if a file exists?

Status
Not open for further replies.

Hangaard

Programmer
Apr 12, 2000
5
DK
I use a password-protection on my homepage, where the password itself is the name of the protected file. <font color=red>Example: Password = phonelist -&gt; opens phonelist.htm</font><br>But if the wrong password is entered, then I get that ugly standard page, saying that the file doesn't exist.<br>Instead I want to check if &quot;password&quot;.htm exists, and then open the file if it does exist, or write a message &quot;Sorry, the entered password is wrong!&quot; if it doesn't.<br>
 
There really isn't any way of doing this since the server will always send a &quot;fake&quot; file that tells the browser to display the message that it doesn't exist.&nbsp;&nbsp;To the browser, the file exists, but only the viewer knows it actually does not exist. <p>REH<br><a href=mailto:hawkdogg@crosswinds.net>hawkdogg@crosswinds.net</a><br><a href= by Linux</a><br>Learn Linux and Leave out the Windows :)
 
You can do this with serverside script using the File.exists() method.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top