PDA

View Full Version : Test existence of directory


tdavis
02-18-2008, 02:22 PM
Can you test for the existence of a directory as well as a folder?

I do this to test for a file:
if (-e "../gallery/$file_name") {
print "The file does exist";
}

I tried this to test for a directory (does not seem to work):
if (-e "../gallery/$directory_name") {
print "The directory does exist";
}.

I thought about globbing the files names into an array and checking that, or creating a dummy file in the directories, but is that the best way to do this? (It doesnt seem like it would be...)

BTW, The search forum no longer works. I keep getting this: Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 55616 bytes) in /home/gchiang/public_html/search.php on line 1033.

Thanks,
-tdavis

oesxyl
02-18-2008, 02:29 PM
try this:


if( -d "../gallery/$file_name"){
# directory exists
}


best regards

tdavis
02-18-2008, 03:00 PM
Thank you. That did work.