Detailed explanation on the implementation of network disk and compressed package functions in PHP file management

黄舟
Release: 2023-03-16 10:02:02
Original
1134 people have browsed it

This article mainly introduces the functional operation of PHP file management to realize network disk and compressed package. Friends in need can refer to the

The implementation code is as follows:

1. Home page File_zip.php


<!DOCTYPE html>
<html>
 <head>
 <meta charset="UTF-8">
 <title>文件管理</title> 
 <script src="bootstrap/js/jquery-1.11.2.min.js"></script> 
 </head>
 <style>
 *{ margin:0px auto; padding:0px}
 #wai{ width:800px;}
 .list{ width:50%; height:35px; background-color:#09F; margin-top:2px; color:white; font-weight:bold; text-align:left; line-height:35px; vertical-align:middle; font-size:28px; padding:5px}
 .mulu{ background-color:#FC9}
 .mulu:hover{ cursor:pointer}
 #prev:hover{ cursor:pointer}
 </style>
 <body>
 <p id="outside">
 <?php
 session_start();
 $fname = "/wamp/www";//使$filename的值为根文件夹中www目录下的所有文件夹
 if(!empty($_SESSION["lujing"])){
 $fname = $_SESSION["lujing"];//把session存储的路径赋值给$fname
 echo "<p id=&#39;prev&#39; class=&#39;list&#39; lj=&#39;{sj}&#39;>返回上一级</p>";
 }  
 ?>
 <p id="inside">
 <?php
 $sj = dirname($fname);
 $dir = opendir($fname);
 $arr = array();//将文件夹与文件合并放入
 $arr1 = array();//放入文件夹
 $arr2 = array();//放入文件
 while($filename = readdir($dir)){//把$fname里面的所有内容遍历出来
 if($filename != "."){
 $ml = $fname."/".$filename;
 if(is_dir($ml)){
 $arr1[ ] = $ml;
 }else{
 $arr2[ ] = $ml;
 }
 }
 }
 $arr = array_merge($arr1,$arr2);
 foreach($arr as $v){
 $filename = basename($v);
 if(is_dir($v)){
 echo "<p lj=&#39;{$ml}&#39; class=&#39;list mulu&#39;>{$filename}</p>";
 }else{
 echo "<p class=&#39;list&#39;>{$filename}</p>";
 }
 }
 closedir($dir); 
 ?> 
 </p>
 </p> 
 </body>
 <script>
 $(".mulu").dblclick(function(){
 var lj = $(this).attr("lj");//取点击内容自己的属性值lj,lj里面存储的是点击的文件夹的目录
 $.ajax({ 
 url:"file_zip_chuli.php",
 data:{lj:lj},
 type:"POST",
 dataType:"TEXT",
 success:function(){
 window.location.href = "file_zip.php";
 }
 });
 })
 $("#prev").dblclick(function(){
 Load();
 })
//双击事件的方法
 function Load(){
 var lj = $(this).attr("lj");
 $.ajax({ 
 url:"file_zip_chuli.php",
 data:{lj:lj},
 type:"POST",
 dataType:"TEXT",
 success:function(){
 window.location.href = "file_zip.php";
 }
 });
 }
 </script>
</html>
Copy after login

2. Main page processing page file_zip_chuli.php


 <?php session_start(); $lj = $_POST["lj"]; $_SESSION["lujing"] = $lj;
Copy after login

Summarize

The above is the detailed content of Detailed explanation on the implementation of network disk and compressed package functions in PHP file management. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!