Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2002
    Location
    Seattle, WA USA
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Checking if file exists - and saying so.

    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 Code:
    <?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:
    PHP Code:
    if(file_exists("ftp://username:password@yoursite.com/file.txt")){
      echo 
    'Server online';
    }else{
      echo 
    'Server offline';

    Thank you very much!

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    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"

  • #3
    New Coder
    Join Date
    Jun 2002
    Location
    Seattle, WA USA
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #5
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    ASP ... grrrrrrr - see your other thread.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •