Hi all,
I ran into a cool function in a google search, called file_exists that would do exactly what I need it to do. Unfortunately, I think something is wrong with the logic I'm using, because it returns a value of null instead of true or false. It seems to work great if I check for something in the base directory, but when I try something outside of the root, it fails. The check file code looks like this:
[code=php]if (file_exists($f ilename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}[/code]
If I say $filename = 'abcdef.php' which exists in the root directory, it returns true and everything is fine. But, if $filename = '/dir1/dir2/abcdef.php', it doesn't return true or false.
Does anyone have any ideas if I am using the correct structure for specifying the directories?
Thanks!
I ran into a cool function in a google search, called file_exists that would do exactly what I need it to do. Unfortunately, I think something is wrong with the logic I'm using, because it returns a value of null instead of true or false. It seems to work great if I check for something in the base directory, but when I try something outside of the root, it fails. The check file code looks like this:
[code=php]if (file_exists($f ilename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}[/code]
If I say $filename = 'abcdef.php' which exists in the root directory, it returns true and everything is fine. But, if $filename = '/dir1/dir2/abcdef.php', it doesn't return true or false.
Does anyone have any ideas if I am using the correct structure for specifying the directories?
Thanks!
Comment