Re: PHP4 readdir is_dir working incorrectly?

From: Date: Thu, 16 Sep 2004 19:23:01 +0000
Subject: Re: PHP4 readdir is_dir working incorrectly?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-196896@lists.php.net to get a copy of this message
John H & John N, Thanks again. I am sure that is it, without a doubt. Laughing at myself - ridiculous oversight on my part! :) LMAO cant beleive I didnt see that earlier and posted to the list. Please join in laughing at me because I have been slinging PHP since early 99 and should have caught that immediately!! heheh LOL Cheers, Kris John Holmes wrote:
----- Original Message ----- From: "Kristopher Spencer-Yates" <kyates@2binteractive.com> To: <php-general@lists.php.net> Sent: Thursday, September 16, 2004 12:55 PM Subject: [PHP] PHP4 readdir is_dir working incorrectly?
//PHP4 $dir_to_scan = "website.com/htdocs"; $dir_handle = opendir($dir_to_scan); while($filename = readdir($dir_handle)){
       if(is_dir($filename)){
               $files_in_scan[] = $filename;
               }
       else{ echo"$filename is not a directory.<br>\n"; }
       }
sort($files_in_scan); print_r($files_in_scan); The above script properly reports that ".", "..", and "images" are drwx[directories] by adding them to the $files_in_scan array. HOWEVER, my problem is that there are other directories.. quite a few actually.. and above script will say, as an example: pdf_directory is not a directory But I know 'pdf_directory' *is* in fact a directory in 'website.com/htdocs'. Is this a problem with PHP4 or have I somehow 'miscoded' what I'm attempting to do?
Your code is checking if "pdf_directory" is a directly where the scirpt is located instead of "website.com/htdocs/pdf_directory". Add "website.com/htdocs/" to is_dir() and this should work. ---John Holmes... .
-- Kristopher Spencer-Yates Dev Mgr/Systems Administration kris@2binteractive.com

« previous php.general (#196896) next »