Simple upload file management system

WBOY
Release: 2016-07-28 08:27:01
Original
1088 people have browsed it
<?php
if(isset($_GET[&#39;type&#39;])){
	$path="attachment/".date("Ymd");
	if($_GET[&#39;type&#39;]=="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>
Copy after login

The above has introduced the simple upload file management system, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!