ID:               29062
 Updated by:       [EMAIL PROTECTED]
 Reported By:      noscript at uni dot de
-Status:           Open
+Status:           Bogus
 Bug Type:         *Directory/Filesystem functions
 Operating System: Windows and Unix both
 PHP Version:      4.3.7
 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

.


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

[2004-07-08 12:34:18] noscript at uni dot de

Description:
------------
This code should read a directory with all subfolders and files. After
that it should delete the whole dir. But it doesnt work. It comes with
a lot of permission denied messages. But Files are deletable and with
unlink() it works in another test script without the array building.
BTW: closedir returns false but I dont know why...

Reproduce code:
---------------
<?php
function readdeldirs($dir)
{
        if($dir[strlen($dir)-1]!='/')$dir.='/';
        $dirs=Array();
        $dh=opendir($dir);
        while(gettype($datei=readdir($dh))!='boolean')
        {
                if($datei!='.' && $datei!='..')
                {
                        
if(is_dir($dir.$datei))$dirs=array_merge($dirs,readdeldirs($dir.$datei));
                        $dirs[]=$dir.$datei;
                }
        }
        
        closedir($dh);
        return $dirs;
}



function deltree($dir)
{
        $load=readdeldirs($dir);
        array_multisort($load, SORT_DESC);
        foreach($load as $del)
        {
                if(is_dir($del))
                {
                        rmdir($del);
                }
                if(is_file($del))
                {
                        unlink($file);
                }
        }
        rmdir($dir);
}

deltree('download');

Expected result:
----------------
Whole directory with all contents is deleted

Actual result:
--------------
Whole of Permission denied messages


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=29062&edit=1

Reply via email to