php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29062 No access for deleting files after building recursive array
Submitted: 2004-07-08 12:34 UTC Modified: 2004-07-08 13:16 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: noscript at uni dot de Assigned:
Status: Not a bug Package: *Directory/Filesystem functions
PHP Version: 4.3.7 OS: Windows and Unix both
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: noscript at uni dot de
New email:
PHP Version: OS:

 

 [2004-07-08 12:34 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-08 13:16 UTC] derick@php.net
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.

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC