View Full Version : Test to see if directory exists on different server

01-07-2004, 12:31 PM
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...

$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?

09-10-2009, 06:40 PM
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.