-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathrmdir.php
More file actions
38 lines (36 loc) · 735 Bytes
/
rmdir.php
File metadata and controls
38 lines (36 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
//循环删除目录和文件函数
error_reporting(0);
header("Content-Type: text/html;charset=utf-8");
function del_dir($dir){
$n_success = 0;
$n_fail = 0;
if($handle = opendir("$dir")){
while( false !== ($item = readdir($handle))){
if($item != "." && $item != ".."){
if (is_dir("$dir/$item")) {
del_dir("$dir/$item");
}else{
if(unlink("$dir/$item")){
$n_success++;
}else{
$n_fail++;
}
}
}
}
closedir( $handle );
if(rmdir($dir)){
$n_success++;
}else{
$n_fail++;
}
$n_success--;
return '删除成功:'.$n_success.',删除失败:'.$n_fail.'!';
}
}
if($_GET['action'] == 'clean_upload_file'){
echo del_dir("./upload");
mkdir("./upload");
}
?>