| |

VerySource

 Forgot password?
 Register
Search
View: 3153|Reply: 15

Failed to delete empty directory circularly? ?

[Copy link]

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-3-2 09:30:01
| Show all posts |Read mode
code show as below:
function deldir ($ dir)
{
   if ($ handle = opendir ($ dir))
{
while (false! == ($ file = readdir ($ handle)))
{
if ($ file! = "."&&$ file! = "..")
{
$ fullpath = $ dir. "/". $ file;
// echo "full path: $ fullpath <br>";
if (is_dir ($ fullpath))
{
deldir ($ fullpath);
}

}
}
echo "to del file: $ dir <br>";
rmdir ($ dir);
closedir ($ handle);
}
}

delfile ($ dir);
deldir ($ dir);


The problems occurred as follows:
to del file: D: / AppServ / www / hy / html / 107/1/2

Warning: rmdir (D: / AppServ / www / hy / html / 107/1/2) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html / 107/1/3

Warning: rmdir (D: / AppServ / www / hy / html / 107/1/3) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html / 107/1/4

Warning: rmdir (D: / AppServ / www / hy / html / 107/1/4) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html / 107/1/5

Warning: rmdir (D: / AppServ / www / hy / html / 107/1/5) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html / 107/1/6

Warning: rmdir (D: / AppServ / www / hy / html / 107/1/6) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html / 107/1/7

Warning: rmdir (D: / AppServ / www / hy / html / 107/1/7) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html / 107/1

Warning: rmdir (D: / AppServ / www / hy / html / 107/1) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html / 107/2

Warning: rmdir (D: / AppServ / www / hy / html / 107/2) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html / 107

Warning: rmdir (D: / AppServ / www / hy / html / 107) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html / yuiop

Warning: rmdir (D: / AppServ / www / hy / html / yuiop) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html

Warning: rmdir (D: / AppServ / www / hy / html) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48

The directory is right (also empty) but it can't be deleted
Hope advice
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-5-12 00:45:01
| Show all posts
By the way delfile ($ dir); this is to clear all the files in the folder After testing, there is no problem
Reply

Use magic Report

0

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-5-12 11:45:01
| Show all posts
Permission denied in D:\AppServ\www\hy\del.php on line 48

Obviously, no permissions, you see if your http access user has permission to delete the directory
Reply

Use magic Report

0

Threads

24

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 Japan

Post time: 2020-5-12 16:00:01
| Show all posts
Permission problem ...
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-5-14 14:00:01
| Show all posts
I would like to ask how to check the permissions
If it is a permission issue, why is my rmdir ("D: / AppServ / www / hy / html / 107/1/3") successful? ?
Reply

Use magic Report

0

Threads

20

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

Post time: 2020-5-15 14:00:01
| Show all posts
ls -l View permissions.
windows view property page
Reply

Use magic Report

0

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-5-16 16:15:02
| Show all posts
sorry did not pay attention to that you are running under the window, you can see if your deleted directory exists D: / AppServ / www / hy / html / 107, in addition, if there is a subdirectory in 107, can it be deleted
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-5-16 17:30:01
| Show all posts
Is it a permission issue? Why the following code is successful, note that the last is to directly delete
// Delete the specified directory
function deldir ($ dir)
{
   if ($ handle = opendir ($ dir))
{
while (false! == ($ file = readdir ($ handle)))
{
if ($ file! = "."&&$ file! = "..")
{
$ fullpath = $ dir. "/". $ file;
// echo "full path: $ fullpath <br>";
if (is_dir ($ fullpath))
{
deldir ($ fullpath);
}

}
}
echo "to del file: $ dir <br>";
rmdir ($ dir);
closedir ($ handle);
}
}
/ ** ///
delfile ($ dir);
deldir ($ dir);
echo "direct to delete file: D: / AppServ / www / hy / html / 107/1/5 <br>";
if (rmdir ("D: / AppServ / www / hy / html / 107/1/5"))
{
 echo "delete succeed";
}
else
{
echo "delete failed";
}

The result appears:
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-5-16 21:15:01
| Show all posts
to del file: D: / AppServ / www / hy / html / 107/1/4

Warning: rmdir (D: / AppServ / www / hy / html / 107/1/4) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html / 107/1/5

Warning: rmdir (D: / AppServ / www / hy / html / 107/1/5) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html / 107/1/6

Warning: rmdir (D: / AppServ / www / hy / html / 107/1/6) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html / 107/1/7

Warning: rmdir (D: / AppServ / www / hy / html / 107/1/7) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html / 107/1

Warning: rmdir (D: / AppServ / www / hy / html / 107/1) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html / 107/2

Warning: rmdir (D: / AppServ / www / hy / html / 107/2) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html / 107

Warning: rmdir (D: / AppServ / www / hy / html / 107) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html / yuiop

Warning: rmdir (D: / AppServ / www / hy / html / yuiop) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
to del file: D: / AppServ / www / hy / html

Warning: rmdir (D: / AppServ / www / hy / html) [function.rmdir]: Permission denied in D:\AppServ\www\hy\del.php on line 48
direct to delete file: D: / AppServ / www / hy / html / 107/1/5
delete succeed

It can be seen that the deletion is successful I check the folder is indeed gone
Can you explain to the prawns?
Reply

Use magic Report

0

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-5-20 19:15:01
| Show all posts
Yeah, no permission
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list