ID:               25846
 Updated by:       [EMAIL PROTECTED]
 Reported By:      notepad at codewalkers dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Directory function related
 Operating System: winXP
 PHP Version:      4.3.4RC1
 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[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

Reply via email to