Heim > php教程 > php手册 > PHP 列出所用文件夹下所有文件及文件夹

PHP 列出所用文件夹下所有文件及文件夹

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Freigeben: 2016-06-21 09:07:20
Original
1123 Leute haben es durchsucht


/************************************
    Name: ListDir
    Author: Riyao Chen
    Version: 0.0.1
    Date: 2006-05-16
    License: GPL


//This class is to list all file & directory follow a directory
//Parameter:$strdir ,which directory you want list; $del_url,the manage URL,


*********************************/
class ListDir{

 var $dir;
 var $edit_url="";
 var $del_url="";
 
 var $num = 0;

 function ListDir($strdir,$del_url="",$edit_url="")
 {
  $this->dir = $strdir;
  $this->del_url = $del_url;
  $this->edit_url = $edit_url;
  }
 
 function MakeDir($StrDir)
 {
 //global $num;
 if (is_dir($StrDir)) {
      if ($dh = @opendir($StrDir)) {
          while (($file = readdir($dh)) !== false) {
          
           $newdir = $StrDir.$file;
           if($file == "." || $file == "..")
               {
                continue;
               }
              
               $this->num = $this->num + 1;
               print str_repeat(" ",$this->num);
              
               if(filetype($newdir)=="dir")
               {
                print "
";
                print "$file  [目录]
\n";
               }
               else
               {
                 
                print "EDIT $file 
\n";
    }
               if(is_dir($newdir))
               {
                $this->MakeDir($newdir."/");
                }
               
               $this->num = $this->num - 1;
          }
         print "
";
      closedir($dh);
      }
 }

 }
 
 function ShowDir()
 {
  $this->MakeDir($this->dir);
  }
}

/*
exemple

include_once("./class.dir.php");
$dir = new ListDir("c:/","http://127.0.0.1/index.php");
$dir->ShowDir();

*/

 



Verwandte Etiketten:
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Aktuelle Ausgaben
Beliebte Empfehlungen
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage