View Full Version : Checking if file exists - and saying so.

02-14-2003, 02:59 AM
Hi, I posted this in the PHP forum athttp://www.codingforums.com/showthread.php?s=&postid=72093

but, since I have not got another response, I decided to see if it could be done in ASP ... (Note, i know nothing of ASP ... does it need to be installed on a system? Or does it normally come with most servers... like Apache on Unix...)

If anyone could give me a little help, I would greatly appreciate it ...

The script I want to emulate from PHP is this:


$file = @fopen("ftp://testserver:servertest@myserver.address.org/test.html", "r");
if (!$file) {
echo '<b id=Off> Offline</b>';
echo '<b id=On> Online</b>';

or, as I have been told is an easier way (even tho I havent been able to make it work) this:

echo 'Server online';
echo 'Server offline';

Thank you very much!

02-14-2003, 06:05 AM
you said in your other thread that you want to check if a file exists in your server, if it does, it will return the server status "Online" and "Offline" otherwise.

If your server is offline, the code you posted wouldn't run at all. It's like you want your computer to check if it is turned on or off. It's a "catch-22" situation or more commonly known in my country as "chicken and egg" :D

02-14-2003, 11:26 AM
Well, no... the file is just a dummy file - it checks to see if it is there - if it is, then it returns online --- but, if it cannot connect to the server (because the server is offline) then it assumes the file does not exist, thus, it returns an Offline ...
Anyway, it used to work perfect ... but I dunno what happened =\

Any suggestions? Thanks!

02-15-2003, 01:10 AM
Well if you're using PHP, I don't know how to help you, but you can check to see if a file exists locally with FileSystemObject in VBScript with ASP (or even on a local machine).

Probably not much help, you should be posting this in the PHP forum instead. I'm going to go ahead and move this post there so you can get better help.

02-15-2003, 05:02 PM
ASP ... grrrrrrr :D - see your other thread.