<?php
$path='./';
$url=$_SERVER['REQUEST_URI'];
if(isset($_GET['dir']))
{
$path=$path.'/'.$_GET['dir'];
}
else
{
$url.='?dir=./';
}
$dh=opendir($path);
if($dh===false)
{
echo "打开出错";
exit;
}
$list=array();
while( ($item=readdir($dh))!==false )
{
$list[]=$item;
}
closedir($dh);
?>
<!doctype html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>文件管理系统</h1>
<table style="border:1px solid red">
<tr>
<td>序号</td>
<td>文件名</td>
<td>操作</td>
</tr>
<?php
foreach ($list as $k => $v)
{
echo "<tr>";
echo "<td>",$k,'</td>';
echo "<td>",$v,'</td>';
echo "<td>";
if(is_dir($path."/".$v))
{
echo '<a href="',$url,'/',$v,'">浏览</a>';
}
else
{
// if(!isset($_GET['dir']))
if(!isset($_GET['dir']))
{
echo '<a href="./',$v,'">查看</a>';
}
else
echo '<a href="./',$_GET['dir'],'/',$v,'">查看</a>';
}
echo"</td>";
echo "</tr>";
}
?>
</table>
<!-- <form action="exercise.php?id=3&username=abc" method="post">
<p><input type="text" name="username" /></p>
<p><input type="submit" value="提交" /></p>
</form> -->
</body>
</html>
php文件管理系统
最新推荐文章于 2024-05-21 09:57:48 发布