PHP 文件操作   打开文件夹

 
  1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2 <html xmlns="http://www.w3.org/1999/xhtml">
  3 <head>
  4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5 <title>无标题文档</title>
  6 <script src="../../Jquery/jquery-1.11.2.min.js"></script>
  7 <style type="text/css">
  8 *{ margin:0px auto; padding:0px}
  9 .file{ width:50%; height:35px; line-height:35px; vertical-align:middle; border:1px solid #63C; margin-top:2px;}
 10 .mulu{ background-color:#63C; color:white}
 11 .prev{ background-color:#F63; color:white}
 12 </style>
 13 </head>
 14 
 15 <body>
 16 <?php
 17 session_start();
 18 
 19 //要显示的文件夹
 20 $fname = "../../../1027";
 21 
 22 if(!empty($_SESSION["url"]))
 23 {
 24     $fname = $_SESSION["url"];
 25 }
 26 
 27 //输出返回上一层的DIV
 28 $jdlj = realpath($fname);
 29 if($jdlj == "D:\\wamp\\www\\1027")
 30 {    
 31 }
 32 else
 33 {
 34     $fuji = dirname($fname);
 35     echo "<div class='file prev' lj='{$fuji}' >返回上一级</div>";
 36 }
 37 
 38 
 39 //遍历文件夹
 40 $dir = opendir($fname);
 41 
 42 while($n = readdir($dir))
 43 {
 44     $url = $fname."/".$n;
 45     if($n!="." && $n!="..")
 46     {
 47         if(is_dir($url))
 48         {
 49             echo "<div class='file mulu' lj='{$url}' >{$n}</div>";
 50         }
 51         else
 52         {
 53             echo "<div class='file' lj='{$url}'>{$n}  
 54             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 55             <input type='button' value='删除' lj='{$url}' class='sc'/> 
 56             </div>";
 57         }
 58     }
 59 }
 60 
 61 closedir($dir);
 62 
 63 
 64 ?>
 65 <input type="text" id="name"/>
 66 <input type="button" value="新建" id="newf" />
 67 
 68 </body>
 69 <script type="text/javascript">
 70 $(".mulu").dblclick(function(){
 71         var url = $(this).attr("lj");
 72         $.ajax({
 73                 url:"chuli.php",
 74                 data:{url:url},
 75                 type:"POST",
 76                 dataType:"TEXT",
 77                 success: function(data){
 78                         window.location.href = "test.php";
 79                     }
 80             });
 81     })
 82     
 83 $(".prev").dblclick(function(){
 84         var url = $(this).attr("lj");
 85         $.ajax({
 86                 url:"chuli.php",
 87                 data:{url:url},
 88                 type:"POST",
 89                 dataType:"TEXT",
 90                 success: function(data){
 91                         window.location.href = "test.php";
 92                     }
 93             });
 94     })
 95 $(".sc").click(function(){
 96         var lj = $(this).attr("lj");
 97         $.ajax({
 98                 url:"shanchu.php",
 99                 data:{lj:lj},
100                 type:"POST",
101                 dataType:"TEXT",
102                 success: function(data){
103                         window.location.href = "test.php";
104                     }
105             });
106     })
107     
108 $("#newf").click(function(){
109         var name = $("#name").val();
110         $.ajax({
111                 url:"xinjian.php",
112                 data:{name:name},
113                 type:"POST",
114                 dataType:"TEXT",
115                 success: function(data){
116                         window.location.href = "test.php";
117                     }
118             });
119     })
120 </script>
121 </html>
界面文件

处理界面

1 <?php
2 session_start();
3 $url = $_POST["url"];
4 $_SESSION["url"] = $url;
PHP 保存全部

删除处理

1 <?php
2 $lj = $_POST["lj"];
3 unlink($lj);
shanchu.php

新建处理

1 <?php
2 session_start();
3 $name = $_POST["name"];
4 
5 $url = $_SESSION["url"];
6 
7 $filename = $url."/".$name;
8 
9 touch($filename);
xinjian.php

 

转载于:https://www.cnblogs.com/ordinaryk/p/6291705.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值