-
php实现WEB在线文件管理器(2)
){
//完成重命名
$str=<<<EOF
<form action="index.php?act=doRename" method="post">
请填写新文件名:<input type="text" name="newname" placeholder="重命名"/>
<input type='hidden' name='filename' value='{$filename}' />
<input type="submit" value="重命名"/>
</form>
EOF;
echo $str;
}elseif($act=="doRename"){
//实现重命名的操做
$newname=$_REQUEST['newname'];
$mes=renameFile($filename,$newname);
alertMes($mes,$redirect);
}elseif($act=="delFile"){
$mes=delFile($filename);
alertMes($mes,$redirect);
}elseif($act=="downFile"){
//完成下载的操作
$mes=downFile($filename);
}elseif($act=="创建文件夹"){
$mes=createFolder($path."/".$dirname);
alertMes($mes,$redirect);
}elseif($act=="renameFolder"){
$str=<<<EOF
<form action="index.php?act=doRenameFolder" method="post">
请填写新文件夹名称:<input type="text" name="newname" placeholder="重命名"/>
<input type="hidden" name="path" value="{$path}" />
<input type='hidden' name='dirname' value='{$dirname}' />
<input type="submit" value="重命名"/>
</form>
EOF;
echo $str;
}elseif($act=="doRenameFolder"){
$newname=$_REQUEST['newname'];
//echo $newname,"-",$dirname,"-",$path;
$mes=renameFolder($dirname,$path."/".$newname);
alertMes($mes,$redirect);
}elseif($act=="copyFolder"){
$str=<<<EOF
<form action="index.php?act=doCopyFolder" method="post">
将文件夹复制到:<input type="text" name="dstname" placeholder="将文件夹复制到"/>
<input type="hidden" name="path" value="{$path}" />
<input type='hidden' name='dirname' value='{$dirname}' />
<input type="submit" value="复制文件夹"/>
</form>
EOF;
echo $str;
}elseif($act=="doCopyFolder"){
$dstname=$_REQUEST['dstname'];
$mes=copyFolder($dirname,$path."/".$dstname."/".basename($dirname));
alertMes($mes,$redirect);
}elseif($act=="cutFolder"){
$str=<<<EOF
<form action="index.php?act=doCutFolder" method="post">
将文件夹剪切到:<input type="text" name="dstname" placeholder="将文件剪切到"/>
<input type="hidden" name="path" value="{$path}" />
<input type='hidden' name='dirname' value='{$dirname}' />
<input type="submit" value="剪切文件夹"/>
</form>
EOF;
echo $str;
}elseif($act=="doCutFolder"){
//echo "文件夹被剪切了";
$dstname=$_REQUEST['dstname'];
$mes=cutFolder($dirname,$path."/".$dstname);
alertMes($mes,$redirect);
}elseif($act=="delFolder"){
//完成删除文件夹的操作
//echo "文件夹被删除了";
$mes=delFolder($dirname);
alertMes($mes,$redirect);
}elseif($act=="copyFile"){
$str=<<<EOF
<form action="index.php?act=doCopyFile" method="post">
将文件复制到:<input type="text" name="dstname" placeholder="将文件复制到"/>
<input type="hidden" name="path" value="{$path}" />
<input type='hidden' name='filename' value='{$filename}' />
<input type="submit" value="复制文件"/>
</form>
EOF;
echo $str;
}elseif($act=="doCopyFile"){
$dstname=$_REQUEST['dstname'];
$mes=copyFile($filename,$path."/".$dstname);
alertMes($mes,$redirect);
}elseif($act=="cutFile"){
$str=<<<EOF
<form action="index.php?act=doCutFile" method="post">
将文件剪切到:<input type="text" name="dstname" placeholder="将文件剪切到"/>
<input type="hidden" name="path" value="{$path}" />
<input type='hidden' name='filename' value='{$filename}' />
<input type="submit" value="剪切文件"/>
</form>
EOF;
echo $str;
}elseif($act=="doCutFile"){
$dstname=$_REQUEST['dstname'];
$mes=cutFile($filename,$path."/".$dstname);
alertMes($mes,$redirect);
}elseif($act=="上传文件"){
//print_r($_FILES);
$fileInfo=$_FILES['myFile'];
$mes=uploadFile($fileInfo,$path);
alertMes($mes, $redirect);
}
?>
<!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">
function show(dis){
document.getElementById(dis).style.display="block";
}
function delFile(filename,path){
if(window.confirm("您确定要删除嘛?删除之后无法恢复哟!!!")){
location.href="index.php?act=delFile&filename="+filename+"&path="+path;
}
}
function delFolder(dirname,path){
if(window.confirm("您确定要删除嘛?删除之后无法恢复哟!!!")){
location.href="index.php?act=delFolder&dirname="+dirname+"&path="+path;
}
}
function showDetail(t,filename){
$("#showImg").attr("src",filename);
$("#showDetail").dialog({
height:"auto",
width: "auto",
position: {my: "center", at: "center", collision:"fit"},
modal:false,//是否模式对话框
draggable:true,//是否允许拖拽
resizable:true,//是否允许拖动
title:t,//对话框标题
show:"slide",
hide:"explode"
});
}
function goBack($back){
location.href="index.php?path="+$back;
}
</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="show('createFile')" 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="show('createFolder')" 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="show('uploadFile')"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>
<?php
$back=($path=="file")?"file":dirname($path);
?>
<li><a href="#" title="返回上级目录" onclick="goBack('<?php echo $back;?>')"><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 id="createFolder" style="display:none;">
<td>请输入文件夹名称</td>
<td >
<input type="text" name="dirname" />
<input type="hidden" name="path" value="<?php echo $path;?>"/>
<input type="submit" name="act" value="创建文件夹"/>
</td>
</tr>
<tr id="createFile" style="display:none;">
<td>请输入文件名称</td>
<td >
<input type="text" name="filename" />
<input type="hidden" name="path" value="<?php echo $path;?>"/>
<input type="submit" name="act" value="创建文件" />
</td>
</tr>
<tr id="uploadFile" style="display:none;">
<td >请选择要上传的文件</td>
<td ><input type="file" name="myFile" />
<input type="submit" name="act" value="上传文件" />
</td>
</tr>
<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>
<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;?>" alt="" title="文件"/></td>
<td><?php echo transByte(filesize($p));?></td>
<td><?php $src=is_readable($p)?"correct.png":"error.png";?><img class="small" src="images/<?php echo $src;?>" alt=""/></td>
<td><?php $src=is_writable($p)?"correct.png":"error.png";?><img class="small" src="images/<?php echo $src;?>" alt=""/></td>
<td><?php $src=is_executable($p)?"correct.png":"error.png";?><img class="small" src="images/<?php echo $src;?>" alt=""/></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>
<td>
<?php
//得到文件扩展名
$ext=strtolower(end(explode(".",$val)));
$imageExt=array("gif","jpg","jpeg","png");
if(in_array($ext,$imageExt)){
?>
<a href="#" onclick="showDetail('<?php echo $val;?>','<?php echo $p;?>')"><img class="small" src="images/show.png" alt="" title="查看"/></a>|
<?php
}else{
?>
<a href="index.php?act=showContent&path=<?php echo $path;?>&filename=<?php echo $p;?>" ><img class="small" src="images/show.png" alt="" title="查看"/></a>|
<?php }?>
<a href="index.php?act=editContent&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/edit.png" alt="" title="修改"/></a>|
<a href="index.php?act=renameFile&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/rename.png" alt="" title="重命名"/></a>|
<a href="index.php?act=copyFile&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/copy.png" alt="" title="复制"/></a>|
<a href="index.php?act=cutFile&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/cut.png" alt="" title="剪切"/></a>|
<a href="#" onclick="delFile('<?php echo $p;?>','<?php echo $path;?>')"><img class="small" src="images/delete.png" alt="" title="删除"/></a>|
<a href="index.php?act=downFile&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/download.png" alt="" title="下载"/></a>
</td>
</tr>
<?php
$i++;
}
}
?>
<!-- 读取目录的操作-->
<?php
if($info['dir']){
$i=$i==null?1:$i;
foreach($info['dir'] as $val){
$p=$path."/".$val;
?>
<tr>
<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;?>" alt="" title="文件"/></td>
<td><?php $sum=0; echo transByte(dirSize($p));?></td>
<td><?php $src=is_readable($p)?"correct.png":"error.png";?><img class="small" src="images/<?php echo $src;?>" alt=""/></td>
<td><?php $src=is_writable($p)?"correct.png":"error.png";?><img class="small" src="images/<?php echo $src;?>" alt=""/></td>
<td><?php $src=is_executable($p)?"correct.png":"error.png";?><img class="small" src="images/<?php echo $src;?>" alt=""/></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>
<td>
<a href="index.php?path=<?php echo $p;?>" ><img class="small" src="images/show.png" alt="" title="查看"/></a>|
<a href="index.php?act=renameFolder&path=<?php echo $path;?>&dirname=<?php echo $p;?>"><img class="small" src="images/rename.png" alt="" title="重命名"/></a>|
<a href="index.php?act=copyFolder&path=<?php echo $path;?>&dirname=<?php echo $p;?>"><img class="small" src="images/copy.png" alt="" title="复制"/></a>|
<a href="index.php?act=cutFolder&path=<?php echo $path;?>&dirname=<?php echo $p;?>"><img class="small" src="images/cut.png" alt="" title="剪切"/></a>|
<a href="#" onclick="delFolder('<?php echo $p;?>','<?php echo $path;?>')"><img class="small" src="images/delete.png" alt="" title="删除"/></a>|
</td>
</tr>
<?php
$i++;
}
}
?>
</table>
</form>
</body>
</html>
栏目列表
最新更新
nodejs爬虫
Python正则表达式完全指南
爬取豆瓣Top250图书数据
shp 地图文件批量添加字段
爬虫小试牛刀(爬取学校通知公告)
【python基础】函数-初识函数
【python基础】函数-返回值
HTTP请求:requests模块基础使用必知必会
Python初学者友好丨详解参数传递类型
如何有效管理爬虫流量?
SQL SERVER中递归
2个场景实例讲解GaussDB(DWS)基表统计信息估
常用的 SQL Server 关键字及其含义
动手分析SQL Server中的事务中使用的锁
openGauss内核分析:SQL by pass & 经典执行
一招教你如何高效批量导入与更新数据
天天写SQL,这些神奇的特性你知道吗?
openGauss内核分析:执行计划生成
[IM002]Navicat ODBC驱动器管理器 未发现数据
初入Sql Server 之 存储过程的简单使用
这是目前我见过最好的跨域解决方案!
减少回流与重绘
减少回流与重绘
如何使用KrpanoToolJS在浏览器切图
performance.now() 与 Date.now() 对比
一款纯 JS 实现的轻量化图片编辑器
关于开发 VS Code 插件遇到的 workbench.scm.
前端设计模式——观察者模式
前端设计模式——中介者模式
创建型-原型模式