日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php 文件管理

發布時間:2025/3/21 php 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php 文件管理 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

方法一只做了(查看)

<!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>無標題文檔</title> <script type="text/javascript" src="../../popwindow/jquery-1.11.2.min.js"></script> </head><body id='body'><?php session_start(); if(empty($_SESSION["url"])) { $_SESSION["url"]="../../zuoye"; } $url=$_SESSION["url"];Guanli($url); function Guanli() { global $url;// 獲取當前文件夾所有內容$attr=glob($url."/*");// 返回上級菜單按鈕echo "<div class='a' url='{$url}'>返回上一級</div>";foreach($attr as $v){//判斷路徑是不是文件if(is_file($v)){ $a=basename($v);echo "<div >$a</div>";}else{ $a=basename($v);echo "<div class='b' url='{$v}' >$a</div>";}} } ?> </body> <script type="text/javascript"> $(document).ready(function(e) {$(".b").click(function(e) {var nr=$(this).attr("url");$.ajax({url:"chuli1.php",data:{nr:nr},dataType:"TEXT",type:"GET",success: function(data){var str=data;$("#body").html(str);window.location="wenjianguanli.php";}}) });$(".a").click(function(e) {var fh=$(this).attr("url");$.ajax({url:"chuli2.php",data:{fh:fh},dataType:"TEXT",type:"GET",success: function(data){var str=data;$("#body").html(str);window.location="wenjianguanli.php";}});}); });</script> </html>

返回上級

<?php session_start(); $fh=$_GET["fh"]; $url=dirname($fh); $_SESSION["url"]=$url; Guanli($url); function Guanli() { global $url;// 獲取當前文件夾所有內容$attr=glob($url."/*");// 返回上級菜單按鈕echo "<div class='a' url='{$url}'>返回上一級</div>";foreach($attr as $v){//判斷路徑是不是文件if(is_file($v)){$a=basename($v);echo "<div>$a</div>";}else{ $a=basename($v);echo "<div class='b' url='{$v}' >$a</div>";}} }

前往子文件夾處理頁面

<?php session_start(); $fh=$_GET["fh"]; $url=dirname($fh); $_SESSION["url"]=$url; Guanli($url); function Guanli() { global $url;// 獲取當前文件夾所有內容$attr=glob($url."/*");// 返回上級菜單按鈕echo "<div class='a' url='{$url}'>返回上一級</div>";foreach($attr as $v){//判斷路徑是不是文件if(is_file($v)){$a=basename($v);echo "<div>$a</div>";}else{ $a=basename($v);echo "<div class='b' url='{$v}' >$a</div>";}} }


方法二利用目錄資源(含刪除)

<!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>無標題文檔</title> <script src="../jquery-1.11.2.min.js"></script><style type="text/css"> *{ margin:0px auto; padding:0px} #wai{ width:300px; font-size:18px; font-weight:bold;} .wj{ width:100%; height:30px; text-align:center; line-height:30px; vertical-align:middle; color:#333; background-color:#0FF; border-top:1px solid #FFF} .ml{ width:100%; height:30px; text-align:center; line-height:30px; vertical-align:middle; color:#333; background-color:#0F6;border-top:1px solid #FFF} #fanhui{width:100%; height:30px; text-align:center; line-height:30px; vertical-align:middle; color:#333; background-color:#F66;border-top:1px solid #FFF} </style> </head><body> <div id="wai"><!--該頁面功能:根據父級目錄(存在session中)找到子文件,并顯示 如果要顯示下級目錄下的子文件:需要將session中的值變成下級目錄的路徑 如果要返回上一級:需要將session中的值變為上級目錄 --><?php session_start();//如果session里面為空,說明是第一次打開頁面,給他默認的文件夾 if(empty($_SESSION["lujing"])) {$_SESSION["lujing"] = "/wamp/www"; } else if($_SESSION["lujing"] != "/wamp/www") {//顯示返回div$fpath = dirname($_SESSION["lujing"]);echo "<div lujing='{$fpath}' id='fanhui']>返回上一級</div>"; }//取出session里的路徑 $lujing = $_SESSION["lujing"];//根據該路徑打開文件夾,遍歷里面的所有文件 //打開目錄資源 $dir = opendir($lujing); //讀取目錄下的文件 while($wenjian = readdir($dir)) {if($wenjian != "." && $wenjian != ".."){//造一個子文件的路徑$cpath = $lujing."/".$wenjian;//判斷該文件是不是目錄if(is_dir($cpath)){echo "<div lujing='{$cpath}' class='ml'>{$wenjian}</div>";}else{echo "<div lujing='{$cpath}' class='wj'>{$wenjian}</div>";}}} //關閉目錄資源 closedir($dir);?> </div> </body> <script type="text/javascript"> $(document).ready(function(e) {//點擊子級目錄$(".ml").click(function(){var path = $(this).attr("lujing");$.ajax({url:"chuli.php",data:{path:path},type:"POST",dataType:"TEXT",success: function(data){window.location = "test.php";}});})//返回按鈕的事件$("#fanhui").click(function(){var path = $(this).attr("lujing");$.ajax({url:"chuli.php",data:{path:path},type:"POST",dataType:"TEXT",success: function(data){window.location = "test.php";}});})//刪除的事件$(".wj").dblclick(function(){var path = $(this).attr("lujing");$.ajax({url:"shanchu.php",data:{path:path},type:"POST",dataType:"TEXT",success: function(data){window.location = "test.php";}});})}); </script> </html>

刪除處理

<?php $path = $_POST["path"]; unlink($path);

跳轉處理頁面

<?php session_start();$path = $_POST["path"]; $_SESSION["lujing"] = $path;

?

轉載于:https://www.cnblogs.com/zoubizhici/p/5639057.html

總結

以上是生活随笔為你收集整理的php 文件管理的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。