#25846 [Bgs->Opn]: is_dir() does not work on any folder other than the current directory
| From: | notepad at codewalkers dot com | Date: | Sun, 12 Oct 2003 23:57:49 +0000 |
| Subject: | #25846 [Bgs->Opn]: is_dir() does not work on any folder other than the current directory | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-48868@lists.php.net to get a copy of this message | ||
ID: 25846
User updated by: notepad at codewalkers dot com
Reported By: notepad at codewalkers dot com
-Status: Bogus
+Status: Open
Bug Type: Directory function related
Operating System: winXP
PHP Version: 4.3.4RC1
New Comment:
the code above DOES concatentate the directory name to the filename
Previous Comments:
------------------------------------------------------------------------
[2003-10-12 19:47:54] wez@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
readdir() returns only the basename of the filenames, not the full
path. You need to manually concatentate the directory name to the
filename.
------------------------------------------------------------------------
[2003-10-12 18:49:20] notepad at codewalkers dot com
Description:
------------
say you have the folder "test" and inside "test" you have:
- images (folder)
- the_following_code.php (file)
inside the "images" folder you have some sub directories.
the_following_code will NEVER return true.
if i use !is_dir instead, it then returns the sub directories as files
instead of folders. this appears to have been an ongoing problem,
perhaps overlooked or under-explained.
Reproduce code:
---------------
function directory($dir)
{
$mydir = opendir($dir);
while(false !== ($file = readdir($mydir)))
{
if($file != "." && $file != "..")
{
if(is_dir($file))
echo "$file<br>\r\n";
elseif(is_dir($mydir.$file))
echo "$file<br>\r\n";
elseif(is_dir($mydir.$file.'/'))
echo "$file<br>\r\n";
}
}
closedir($mydir);
}
$path = '/inetpub/wwwroot/Scripts/test/images/';
directory($path);
Expected result:
----------------
i expect a list of sub dirs..
Actual result:
--------------
i get nothing.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25846&edit=1