# 文件管理原碼
>[success]
~~~
<html>
<head>
<title>文件管理</title>
<meta charset='utf-8' />
</head>
<body>
<?php
//定義要查看的目錄
$dir="/";
//先判斷$_GET['a']是否已經傳值 防止NOTICE錯誤
if(isset($_GET['a'])){
//選擇判斷要執行的操作
switch($_GET['a']){
case 'creat':
//新建文件
$filename=$_POST["filename"];
$filename=rtrim($dir,"/")."/".$filename;
//寫入文件 寫入一個空字符串
file_put_contents($filename,"");
break;
case 'del':
//刪除文件
unlink($_GET['filename']);
break;
case 'update':
//修改文件
file_put_contents($_POST['filename'],$_POST['content']);
echo "修改成功";
header("refresh:1;url=index.php");
break;
}
}
?>
<center>
<h1>文件管理</h1>
<form action='index.php?a=creat' method='post'>
文件:<input type='text' name='filename' />
<input type='submit' value='新建' />
</form>
<table border='1' width='900' cellpadding='5' cellspacing='0'>
<tr>
<th>文件名</th>
<th>類型</th>
<th>大小</th>
<th>創建時間</th>
<th>操作</th>
</tr>
<?php
//遍歷目錄
$dd=opendir($dir);
while(false !== ($f=readdir($dd))){
//過濾點
if($f == "." || $f == ".."){
continue;
}
//拼路徑
$file=rtrim($dir,"/")."/".$f;
//防止中文亂碼
$f2=iconv("gb2312","utf-8",$f);
echo "<tr>";
echo "<td>{$f2}</td>";
echo "<td>".filetype($file)."</td>";
echo "<td>".filesize($file)."</td>";
echo "<td>".filectime($file)."</td>";
echo "<td align='center'>
<a href='index.php?a=edit&filename={$file}'>修改</a>|
<a href='index.php?a=del&filename={$file}'>刪除</a>
</td>";
echo "</tr>";
}
?>
</table>
<?php
if(isset($_GET['a']) && $_GET['a']=='edit'){
echo "<hr/>";
echo "<form action='index.php?a=update' method='post'>";
echo "文件名:<input type='text' name='filename' readonly value='{$_GET['filename']}' />";
echo "<br/><br/>";
echo "<textarea name='content' rows='5' cols='30'>".file_get_contents($_GET['filename'])."</textarea>";
echo "<br/><br/>";
echo "<input type='submit' value='保存修改' />";
echo "</form>";
}
?>
</center>
</body>
</html>
~~~
- 前言
- PHP獲取服務器信息
- PHP中的常用函數-新手必備知識
- 日期時間相關的函數
- 時區設置
- time函數
- strtotime 時間戳
- date函數
- mktime函數
- 聯合使用 date() 和 mktime()
- PHP數據類型相關的函數
- PHP數組相關的函數
- array函數
- 數組的排序
- sort()和rsort()函數
- asort()和arsort()函數
- ksort()和krsort()函數
- array_multisort()函數
- array_reverse函數
- 數組的遍歷
- 數組中新增和刪除元素
- 數組頭部插入和刪除元素
- 數組尾部插入和刪除元素
- 刪除數組中重復的元素
- 刪除數組中指定的元素
- 數組的合并
- 隨機/打亂已知數組
- range函數
- 數組去除重復
- PHP常用功能函數
- URL地址處理函數
- post/get請求
- PHP字符串相關的函數
- PHP文件系統
- PHP正則表達式
- 正則表達式語法規則
- POSIX擴展的正則表達式函數
- 查找字串函數
- 替換字符串函數
- Perl兼容的正則表達式函數
- PHP中類的應用
- 中文編碼
- 關于stdClass
- 變量相關函數
- unset
- PHP數值相關的函數
- 數值取整
- 開發工具與開發環境使用技巧
- sublime
- 常用插件
- Atom
- 常用插件
- 常見問題
- Visual Studio Code
- vscode常用插件
- 編程推薦字體
- MAC下開發常識
- MAC下的常用設置
- MAC下的常用開發工具
- MAC下XAMMP的常見問題
- Apache配置基礎
- PhpStrom
- php中的常見問題
- 文件上傳相關問題
- API接口中常見問題
- 關于緩沖區問題
- PHP中注意事項
- 條件判斷
- PHP文件管理模塊
- 文件管理源碼
- 文件管理的常用函數
- 文件管理中文亂碼處理
- 自定義功能函數
- 文件下載
- PHP常用頭信息定義匯總
- 常見PHP網頁木馬
- 加密算法
- 1. Base58可逆加密
- 2. AES加密/解密
- mysql數據庫操作
- 命令行操作Mysql常用令行-查詢
- 命令行操作Mysql常用令行-操作
- Mysql使用中的技巧
- 在線數據庫管理中常用命令
- sql show命令
- mysql數據庫的備份與恢復
- 二進制日志介紹
- 二進制日志常用命令
- ThinkPHP
- 數據遷移
- 常見問題
- 驗證碼問題
- API接口中的異常處理
- API接口安全
- 解決跨域問題
- 自定義實用功能函數