...

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



Chicano
02-14-2003, 03: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:





<?php

$file = @fopen("ftp://testserver:servertest@myserver.address.org/test.html", "r");
if (!$file) {
echo '<b id=Off> Offline</b>';
exit;
}else{
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:




if(file_exists("ftp://username:password@yoursite.com/file.txt")){
echo 'Server online';
}else{
echo 'Server offline';
}



Thank you very much!

glenngv
02-14-2003, 07: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

Chicano
02-14-2003, 12:26 PM
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!

whammy
02-15-2003, 02: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.

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum