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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    262
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Test to see if directory exists on different server

    Any ideas on how to check if a directory exists on a file server?

    Here is my code but i can't get it to work...

    PHP Code:
    $path '//fsit01/it/development';exit("Path is: $path"); 
    $folder 'Projects';  
    $test $path.'/'.$folder;  
    print 
    '<br>Path to Directory = ' $test;  
    if (
    is_dir ($test)) {
      print 
    "<br><br>++Dir exists" '[' $test .']';  
      }  else {  
      print 
    "<br><br>--Dir doesn't exist" '[' $test .']';  
      } 
    It doesn't print anything

    Any ideas on how to see if a directory exists?

  • #2
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

    Your code executes perfectly, as it is written; however, it does not fucntion like you expect it to. This is called a logic error.

    The problem is on the first line of the code:

    $path = '//fsit01/it/development';exit("Path is: $path");

    there are 2 statements on this line:

    $path = '//fsit01/it/development';
    exit("Path is: $path");

    What happens is you set the path variable then exit the code, returning the text: "Path is $path" Since you are not calling it from anywhere, this return value is lost.

    Comment out or remove the exit function and it should work pefectly.

    --Dave


  •  

    Posting Permissions

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