php中的TreeView目录结构

时间:2016-11-08 11:23:09

标签: php jquery mysql

  • 如何显示当前目录中可用的所有文件和文件夹php(FTP)
  • 请参阅附图图示例....

Tree View Image

1 个答案:

答案 0 :(得分:1)

define('SITE_URL',"http://yourdomain.com");

function listFolderFiles($dir){
   $fileFolderList = scandir($dir);
   echo '<ul>';
   foreach($fileFolderList as $fileFolder){
       if($fileFolder != '.' && $fileFolder != '..'){
           if(!is_dir($dir.'/'.$fileFolder)){
               echo '<li><a target="_blank" href="'.SITE_URL.'/'.ltrim($dir.'/'.$fileFolder,'./').'">'.$fileFolder.'</a>';
           } else {
               echo '<li>'.$fileFolder;
           }
           if(is_dir($dir.'/'.$fileFolder)) listFolderFiles($dir.'/'.$fileFolder);
               echo '</li>';
           }
   }
   echo '</ul>';
}
listFolderFiles('uploads/'); // function call with directory path (e.g. : upload/)