【慕课网】WEB在线文件管理器
电脑中对文件进行相关操作:
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
新建,重命名,得到相关信息,名字类型,创建时间,访问权限,可读可执行,
复制,删除,双击,创建文件夹,编辑,
文件相关操作:
- 创建文件
- 判断文件的权限
- 文件的大小
- 文件创建时间、修改时间、访问时间
- 查看文件的内容
- 修改文件的内容
- 删除文件
- 重命名文件
- 复制、剪切
- 上传和下载
文件夹相关操作
- 新建文件夹
- 判断文件夹权限
- 文件夹大小
- 文件夹的创建、修改、访问时间
- 查看文件内容
- 重命名
- 复制、剪切
- 下载
获得首层信息
需要得到目录中的内容,
通过遍历目录实现
<?phpfunction readDirectory ($path){$handle = opendir($path);while (($item = readdir($handle))!== false){// .和..这两个特殊的目录// 做不了操作if ($item != "." && $item != ".."){if (is_file ($path."/".$item)){$arr['file'][] = $item;}else if(is_dir ($path."/".$item)) {$arr['dir'][] = $item;}}}closedir($handle);return $arr;}$path = "file";print_r (readDirectory($path));?>
列表显示文件大小
index.html
<!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" /><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></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><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></body></html>
显示文件名:
<?phprequire_once 'dir.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" /><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></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><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><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><?phpif ($info['file']){$i = 1;foreach ($info['file'] as $val){?><tr><td><?php echo $i ;?></td><td><?php echo $val;?></td><td><?php echo filetype($path."/".$val);?></td></tr><?php$i++;}}?></table></body></html>

修改为图片:
<?phprequire_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" /><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></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><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><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><?phpif ($info['file']){$i = 1;foreach ($info['file'] as $val){?><tr><td><?php echo $i ;?></td><td><?php echo $val;?></td><td><?php $src = filetype($path."/".$val) == "file" ? "file_ico.png" : "folder_ico.png";?><img src = "images/<?php echo $src;?>" alt = "" title="文件"/></td><td><?php echo transByte(filesize ($path."/".$val));?></td></tr><?php$i++;}}?></table></body></html>

构建file.func.php,转换字符大小
<?php/* 转换字符大小。@parameter number $size@return number */function transByte ($size){// $size = 500000;$arr = array ("B","KB","MB","GB","TB","EB");$i = 0;while ($size >= 1024){$size/=1024;$i++;}// 取两位小数return round($size,2).$arr[$i];}?>
可读:
<td><?php $src = is_readable ($path ."/".$val) ? "correct.png" : "error.png";?><img class="small" src = "images/<?php echo $src;?>" alt = ""/></td>
创建时间:
<td><?php echo filectime($p);?></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>
创建文件
文件名的合法性:不能包含/:*"等特殊字符。
检测当前目录下是否存在同名文件
<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><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>
<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>
把样式变成显示。
当触碰按钮的时候才显示。平时隐藏,点击的时候,调用show,把style变为block
<tr id="createFolder" style="display:none;">
<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>
隐藏域:传路径
操作:
<?phprequire_once 'dir.func.php';require_once 'file.func.php';$path = "file";$info = readDirectory($path);// print_r ($info);// $act = $_REQUEST['act'];$act=$_REQUEST['act'];$filename = $_REQUEST['filename'];$redirect = "index.php?path=${path}";if ($act == "创建文件"){// echo $path , "--";// echo $filename;// 创建文件$mes = createFile($path."/".$filename);// alertMes($mes,$redirect);}?>
function createFile ($filename){// 验证文件名的合法性$pattern = "/[\/,\*,<>,\?,\|]/";// $filename的形式为file/1.txt,所以需要进行处理if(!preg_match($pattern , basename($filename))){// 检测当前目录是否包含同名文件if(!file_exists($filename)){// 通过touch创建if(touch($filename)){return "文件创建成功";}else {return "文件创建失败";}}else {return "文件已存在,请重命名以后创建";}}else{return "非法文件名";}}
定义一个公共函数
告诉用户是否创建成功。
/*** 提示操作信息的,并且跳转* @param string $mes* @param string $url*/function alertMes($mes,$url){echo "<script type='text/javascript'>alert('{$mes}');location.href='{$url}';</script>";}
在index.php里面加上
<?phprequire_once 'dir.func.php';require_once 'file.func.php';require_once 'common.func.php';$path = "file";$info = readDirectory($path);// print_r ($info);// $act = $_REQUEST['act'];$act=$_REQUEST['act'];$filename = $_REQUEST['filename'];// 跳转变量$redirect = "index.php?path=${path}";if ($act == "创建文件"){// echo $path , "--";// echo $filename;// 创建文件$mes = createFile($path."/".$filename);alertMes($mes,$redirect);}?>
http://127.0.0.1/project/fileManager/index.php?path=file

查看文件内容
通过file_get_contents($filename)得到文件内容
通过highlight_string($string)或者highlight_file($filename)显示内容
使用PHP内置的语法高亮器所定义的颜色,打印输出或者返回输出或者返回语法高亮版本的PHP代码。
<?phprequire_once 'dir.func.php';require_once 'file.func.php';require_once 'common.func.php';$path = "file";$info = readDirectory($path);// print_r ($info);// $act = $_REQUEST['act'];$act=$_REQUEST['act'];$filename = $_REQUEST['filename'];// 跳转变量$redirect = "index.php?path=${path}";if ($act == "创建文件"){// echo $path , "--";// echo $filename;// 创建文件$mes = createFile($path."/".$filename);alertMes($mes,$redirect);}elseif ($act == "showContent"){// 查看文件内容$content = file_get_contents($filename);// echo $content;// echo "<textarea readonly = 'readonly' cols='100' rows = '10'>{$content}</textarea>";// 高亮显示PHP代码// 第二个参数是true的话可以返回值$newContent = highlight_string($content , true);// 高亮显示文件中的PHP代码// highlight_file($filename);// 放到表格中$str = <<<EOF<table width = '100%' bgcolor = 'pink' cellpadding = '5' cellspacing = '0' ><tr><td>{$newContent}</td></tr></table>EOF;echo $str;}?>
如果文件本来就没东西,则需要加个判断。
str需要高亮的PHP代码,应当包含开始标签。
return设置该参数为 TRUE 使函数返回高亮后的代码。
修改

<?phprequire_once 'dir.func.php';require_once 'file.func.php';require_once 'common.func.php';$path = "file";$info = readDirectory($path);// print_r ($info);// $act = $_REQUEST['act'];$act=$_REQUEST['act'];$filename = $_REQUEST['filename'];// echo $filename;// 跳转变量$redirect = "index.php?path=${path}";if ($act == "createFile"){// echo $path , "--";// echo $filename;// 创建文件$mes = createFile($path."/".$filename);alertMes($mes,$redirect);}elseif ($act == "showContent"){// 查看文件内容$content = file_get_contents($filename);if (strlen($content)){// echo $content;// echo "<textarea readonly = 'readonly' cols='100' rows = '10'>{$content}</textarea>";// 高亮显示PHP代码// 第二个参数是true的话可以返回值$newContent = highlight_string($content , true);// 高亮显示文件中的PHP代码// highlight_file($filename);// 放到表格中$str = <<<EOF<table width = '100%' bgcolor = 'pink' cellpadding = '5' cellspacing = '0' ><tr><td>{$newContent}</td></tr></table>EOF;echo $str;}else{alertMes("文件没有,请编辑",$redirect);}}elseif($act == "editContent"){// echo "编辑文件";// 此时返回的$filename已经包含了路径了。$content = file_get_contents($filename);// echo $content;$str=<<<EOF<form action='index.php?act=doEdit' method='post'><textarea name='content' cols='190' rows='10'>{$content}</textarea><br/><input type='hidden' name = 'filename' value = {$filename}><input type = 'hidden' name='path' value = {$path}><input type="submit" value="修改文件内容"/></form>EOF;echo $str;}elseif($act=="doEdit"){//修改文件内容的操作$content=$_REQUEST['content'];echo $content;// 此时还没有传$filenameif(file_put_contents($filename,$content)){$mes="文件修改成功";}else{$mes="文件修改失败";}alertMes($mes,$redirect);}?>
查看图片
- 如果是图片类型,点击查看直接显示图片
- 如果不是图片,可以显示文件中的内容
- 用到jQuery UI中的Dialog来显示图片
官网:jqueryui.com
通过文件的扩展名来获得图片类型。
引用:
<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"/>
JS:设置
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"});}
布局中:
<div id="showDetail" style="display:none"><img src="" id="showImg" alt=""/></div>
<td><?php// 得到文件扩展名$ext = strtolower(end(explode(".",$val)));$imagExt = array ("gif","jpg","jpeg","png");if (in_array($ext , $imagExt)){?><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 }?>
explode:以“.”作为分隔符
取最后一个,全部转换为小写。
如果$ext在$imagExt里面,
当点击的时候调用showDetail,传入文件名和路径。
重命名文件


<a href="index.php?act=renameFile&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/rename.png" alt="" title="重命名"/></a>|
把renameFile传递过去,
使用PHP显示一个表格。
act= doRename
注意要同时把$filename也传递过去。
}elseif($act == "renameFile"){// 重命名$str = <<<EOF<form action = "index.php?act=doRename" method = "post" >请填写新文件名:<input type="text" name = "newname" placeholder="重命名"/></br><input type='hidden' name='filename' value='{$filename}'/><input type = 'submit' value='重命名'/></form>EOF;echo $str;}elseif($act == "doRename"){// 实现重命名操作$newname = $_REQUEST['newname'];// echo $newname;$mes = renameFile($filename,$newname);alertMes ($mes , $redirect);}
通过文本框填写的内容获得$newname,调用renameFile函数,在file.func.php里面。
/*** 重命名文件* @param string $oldname* @param string $newname* @return string*/function renameFile($oldname,$newname){// echo $oldname,$newname;//验证文件名是否合法if(checkFilename($newname)){//检测当前目录下是否存在同名文件$path=dirname($oldname);if(!file_exists($path."/".$newname)){//进行重命名if(rename($oldname,$path."/".$newname)){return "重命名成功";}else{return "重命名失败";}}else{return "存在同名文件,请重新命名";}}else{return "非法文件名";}}/***检测文件名是否合法* @param string $filename* @return boolean*/function checkFilename($filename){$pattern = "/[\/,\*,<>,\?\|]/";if (preg_match ( $pattern, $filename )) {return false;}else{return true;}}
删除文件

function delFile(filename,path){if(window.confirm("您确定要删除嘛?删除之后无法恢复哟!!!")){location.href="index.php?act=delFile&filename="+filename+"&path="+path;}}
传入一个操作delFile

}elseif($act == "delFile"){// echo "文件删除";$mes = delFile($filename);alertMes($mes,$redirect);}elseif($act == "downFile"){// 完成下载操作$mes = downFile($filename);}
下载文件

}elseif($act == "downFile"){// 完成下载操作$mes = downFile($filename);}
function downFile($filename){header("content-disposition:attachment;filename=".basename($filename));header("content-length:".filesize($filename));readfile($filename);}
文件夹
查看文件夹
显示目录的布局文件。
<!-- 读取目录的操作--><?phpif($info['dir']){$i=$i==null?1:$i;foreach($info['dir'] as $val){$p=$path."/".$val;echo $p;?><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++;}}?>
在dir.func.php里面加入
$sum是全局变量,避免调用的时候被释放,得不到所有目录里面的结果。
递归调用
function dirSize ($path){$handle = opendir ($path);$sum = 0;global $sum;while(($item = readdir($handle))!== false){if ($item != "." && $item != ".."){if(is_file($path."/".$item)){$sum += filesize($path."/".$item);// echo $sum;}if (is_dir($path."/".$item)){$func = __FUNCTION__;$func($path."/".$item);}}}closedir($handle);return $sum;}$path = "file";echo dirSize($path);
每次都要把$sum清空为0,不然就会出现累加的情况。
<td><?php $sum=0; echo transByte(dirSize($p));?></td>
查看文件夹
<a href="index.php?path=<?php echo $p;?>" ><img class="small" src="images/show.png" alt="" title="查看"/></a>|
$path=$_REQUEST['path']?$_REQUEST['path']:$path;
if(!$info){echo "<script text/javascript>alert('空的');location.href='index.php';</script>";}
返回上一级
<?php$back = ($path == "file")? "file" : dirname($path);?>
如果当前的$path已经是主目录file了,则保持当前的目录,如果不是则返回上一层。
function goBack($back){location.href="index.php?path="+$back;}
<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>
复制文件夹
目录函数库里面没有直接复制文件夹的函数,
可以通过复制其中的文件和创建目录来实现目录的复制。
}elseif($act == "copyFolder"){$str = <<<EOF<form action = "index.php?act=doCopyFolder" method = "post" >将文件夹复制到:<input type="text" name = "dstname" placeholder="将文件夹复制到"/></br><input type='hidden' name='filename' value='{$filename}'/><input type = 'submit' value='文件夹复制'/></form>EOF;echo $str;}
若复制的文件夹不存在,新建
如果存在,则需要看是否存在相同名称的文件夹。
如果没有,则创建。
如果有,则把里面的内容复制到里面。
也可以参见简书主页:https://www.jianshu.com/u/482f183ec380
浙公网安备 33010602011771号