|
Posted by Scoop on 09/30/06 14:50
I am new to php and not much of a developer to begin with. I am trying
to write what seems like it should be a simple piece of code but I
can't get it to work.
I'm trying to check if a file exists. If it is in the directory where
the php page is, I'd like to echo the name of the file. If it doesn't
exist, I'd like to back up a directory and check again. I'd like it to
continue backing up, one directory at a time until the file is found,
then echo the relative file location as ../../file.html where there is
one ../ per directory that needed to be traversed. Here is what I
have:
<?php
$file_path = 'file.htm';
do {
$globcheck = glob($file_path);
$homefile_path = '../'.$file_path;
} while(!empty($globcheck));
?>
<?php echo $file_path; ?>
Can someone tell me what I'm doing wrong?
Navigation:
[Reply to this message]
|