国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > PHP > 正文

php_web文件管理系統_day01

2019-11-08 00:52:32
字體:
來源:轉載
供稿:網友

效果圖

這里寫圖片描述

文件遍歷

<?php //打開指定目錄/** * 遍歷目錄函數,只讀取目錄中的最外層的內容 * @param string $path * @return array */function readDirectory($path) { $handle = opendir ( $path ); while ( ($item = readdir ( $handle )) !== false ) { //.和..這2個特殊目錄 if ($item != "." && $item != "..") { if (is_file ( $path . "/" . $item )) { $arr ['file'] [] = $item; } if (is_dir ( $path . "/" . $item )) { $arr ['dir'] [] = $item; } } } closedir ( $handle ); return $arr;}

轉換字節大小

<?php //Bytes/Kb/Mb/Gb/Tb/Eb/** * 轉換字節大小 * @param number $size * @return float */function transBytes($size) { $arr = array("Byte", "KB", "MB", "GB", "TB", "EB"); $i = 0; while($size >= 1024) { $size /= 1024; $i++; } return round($size,2).$arr[$i];}?>

index.php

<?php require_once 'dir.func.php';require_once 'file.func.php';$path="file";$info=readDirectory($path);//PRint_r($info)?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Insert title here</title><link rel="stylesheet" href="cikonss.CSS" /><script src="jquery-ui/js/jquery-1.10.2.js"></script><script src="jquery-ui/js/jquery-ui-1.10.4.custom.js"></script><script src="jquery-ui/js/jquery-ui-1.10.4.custom.min.js"></script><link rel="stylesheet" href="jquery-ui/css/ui-lightness/jquery-ui-1.10.4.custom.css" type="text/css"/><style type="text/css"> body,p,div,ul,ol,table,dl,dd,dt{ margin:0; padding: 0; } a{ text-decoration: none; } ul,li{ list-style: none; float: left; } #top{ width:100%; height:48px; margin:0 auto; background: #E2E2E2; } #navi a{ display: block; width:48px; height: 48px; } #main{ margin:0 auto; border:2px solid #ABCDEF; } .small{ width:25px; height:25px; border:0;}</style><script type="text/javascript"></script></head><body><div id="showDetail" style="display:none"><img src="" id="showImg" alt=""/></div><h1>在線文件管理器</h1><div id="top"> <ul id="navi"> <li><a href="index.php" title="主目錄"><span style="margin-left: 8px; margin-top: 0px; top: 4px;" class="icon icon-small icon-square"><span class="icon-home"></span></span></a></li> <li><a href="#" onclick="" title="新建文件" ><span style="margin-left: 8px; margin-top: 0px; top: 4px;" class="icon icon-small icon-square"><span class="icon-file"></span></span></a></li> <li><a href="#" onclick="" title="新建文件夾"><span style="margin-left: 8px; margin-top: 0px; top: 4px;" class="icon icon-small icon-square"><span class="icon-folder"></span></span></a></li> <li><a href="#" onclick=""title="上傳文件"><span style="margin-left: 8px; margin-top: 0px; top: 4px;" class="icon icon-small icon-square"><span class="icon-upload"></span></span></a></li> <li><a href="#" title="返回上級目錄" onclick=""><span style="margin-left: 8px; margin-top: 0px; top: 4px;" class="icon icon-small icon-square"><span class="icon-arrowLeft"></span></span></a></li> </ul></div><form action="index.php" method="post" enctype="multipart/form-data"><table width="100%" border="1" cellpadding="5" cellspacing="0" bgcolor="#ABCDEF" align="center"> <tr> <td>編號</td> <td>名稱</td> <td>類型</td> <td>大小</td> <td>可讀</td> <td>可寫</td> <td>可執行</td> <td>創建時間</td> <td>修改時間</td> <td>訪問時間</td> <td>操作</td> </tr> <?php if($info['file']) { $i = 1; foreach ($info['file'] as $val) { $p = $path."/".$val; ?> <tr> // 核心代碼start <td><?php echo $i;?></td> <td><?php echo $val;?></td> <td><?php $src = filetype($p)=="file"?"file_ico.png":"folder_ico.png";?><img src="images/<?php echo $src;?>"></img></td> <td><?php echo transBytes(filesize($p))?></td> <td><?php $src = is_readable($p)?"correct.png":"error.png"?><img src="images/<?php echo $src;?>" title="可讀" height="50px" width="50px"/></td> <td><?php $src = is_writable($p)?"correct.png":"error.png"?><img src="images/<?php echo $src;?>" title="可寫" height="50px" width="50px"/></td> <td><?php $src = is_executable($p)?"correct.png":"error.png"?><img src="images/<?php echo $src;?>" title="可執行" height="50px" width="50px"/></td> <td><?php echo date("Y-m-d H:i:s", filectime($p))?></td> <td><?php echo date("Y-m-d H:i:s", filemtime($p))?></td> <td><?php echo date("Y-m-d H:i:s", fileatime($p))?></td> // 核心代碼end <td> <a href="index.php?act=showContent&path=&filename=" ><img class="small" src="images/show.png" alt="" title="查看"/></a>| <a href="index.php?act=editContent&path="><img class="small" src="images/edit.png" alt="" title="修改"/></a>| <a href="index.php?act=renameFile&path=&filename="><img class="small" src="images/rename.png" alt="" title="重命名"/></a>| <a href="index.php?act=copyFile&path=&filename="><img class="small" src="images/copy.png" alt="" title="復制"/></a>| <a href="index.php?act=cutFile&path=&filename="><img class="small" src="images/cut.png" alt="" title="剪切"/></a>| <a href="#" onclick="')"><img class="small" src="images/delete.png" alt="" title="刪除"/></a>| <a href="index.php?act=downFile&path=&filename="><img class="small" src="images/download.png" alt="" title="下載"/></a> </td> </tr> <?php $i++; } } ?></table></form></body></html>
上一篇:PHP學習一

下一篇:PHP的日期和時間

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平乐县| 云安县| 安义县| 安化县| 太湖县| 松溪县| 平定县| 施甸县| 土默特左旗| 德钦县| 五常市| 朝阳区| 金阳县| 望城县| 开原市| 密云县| 江山市| 通州区| 清涧县| 青岛市| 宁武县| 乐陵市| 额济纳旗| 山阳县| 白沙| 板桥市| 琼结县| 宁化县| 江都市| 阆中市| 石棉县| 富顺县| 信宜市| 郑州市| 浦北县| 宜兴市| 太保市| 岱山县| 新乡县| 南充市| 龙川县|