<?php
if(isset($_GET['type'])){
$path="attachment/".date("Ymd");
if($_GET['type']=="0"){
if(!file_exists($path)){
mkdir($path);
}
if(move_uploaded_file($_FILES["file"]["tmp_name"], $path."/" . $_FILES["file"]["name"])){
echo "<span style=\"color:red\">上传成功!</span>  <a href=\"index.php\">返回</a>";
}else{
echo "<span style=\"color:red\">上传失败!</span>  <a href=\"index.php\">返回</a>";
}
}else{
if(unlink($path."/".$_GET["filename"])){
echo "<span style=\"color:red\">删除成功!</span>  <a href=\"index.php\">返回</a>";
}else{
echo "<span style=\"color:red\">删除失败!</span>  <a href=\"index.php\">返回</a>";
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>上传文件管理</title>
<style type="text/css">
a{
color:#000;
text-decoration:none;
}
</style>
</head>
<body>
<form action="?type=0" method="post" enctype="multipart/form-data" name="form1">
<label for="file"></label>
<input type="file" name="file" id="file" style="width:348px">
<input type="submit" name="button" id="button" value="上传">
</form>
<br />
<table width="400" border="1" cellpadding="0" cellspacing="0" style="text-align:center">
<tr>
<td width="70%">文件名</td>
<td colspan="2">操作</td>
</tr>
<?php
$path="attachment/".date("Ymd");
$filesnames = scandir($path);
foreach ($filesnames as $filename) {
if($filename!="." && $filename !=".."){
$name= iconv("GBK","UTF-8//IGNORE",$filename);
echo "<tr>";
echo "<td style=\"text-align:left\">".$name."</td>";
echo "<td><a href=\"".$path."/".$name."\">下载</a></td>";
echo "<td><a href=\"?type=1&filename=".$name."\">删除</a></td>";
echo "</tr>";
}
}
?>
</table>
</body>
</html>以上就介绍了 简易上传文件管理系统,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号