<?php
$path=‘./‘;
if(isset($_GET[‘dir‘])){
$path=$path."./".$_GET[‘dir‘];
}
$dh=opendir($path);
if($dh===false){
echo ‘打开出错‘;
exit;
}
while(($item = readdir($dh))!==false){
$list[]=$item;
}
print_r($list);
closedir($dh);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>文件管理系统</h1>
<table>
<tr>
<td>序号</td>
<td>文件名</td>
<td>操作</td>
</tr>
<?php foreach ($list as $key => $value) { ?>
<tr>
<td><?php echo $key ?></td>
<td><?php echo $value ?></td>
<td><?php
if(is_dir($path.‘./‘.$value)) {
echo ‘<a href="filedir.php?dir=‘,$value,‘">浏览</a>‘;
}
?></td>
</tr>
<?php } ?>
</table>
</body>
</html>
原文地址:http://blog.51cto.com/13757802/2118846
时间: 2024-10-18 03:18:21