Home >Backend Development >PHP Tutorial >[Original] PHP+ajax implements simulated Win file management system 2_PHP tutorial

[Original] PHP+ajax implements simulated Win file management system 2_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:59:57997browse

[Original] php+ajax implements simulated Win file management system

//This tutorial is original from this site, please indicate the source when reprinting

Author: www.drise.cn

Email:drise@163.com

QQ:271728967//

Continuing from the above, let’s look at the dir.php file code:





Untitled Document





$dir_path=isset($_GET['url'])?$_GET['url']:'..';

//$totallen = strlen($dir_path);


//$sublen = strlen(substr($dir_path,strrpos($dir_path,"/")));


$lastdir = substr($dir_path,0,strlen($dir_path)-strlen(substr($dir_path,strrpos($dir_path,"/"))));


Tool($dir_path,$lastdir);


CheckDir($dir_path);


//echo "
";



//echo substr($dir_path,0,(strlen($dir_path)-strrpos($dir_path,"/")+1));



function CheckDir($dir_path){// This function checks and displays the files and files in the current directory


if(is_dir($dir_path)){


If($dir_file=opendir($dir_path)){


While(($dir_list=readdir($dir_file))!==false)


{


If($dir_list!="." && $dir_list!=".."){//If you add this to judge and wait until the file list is displayed... like this.


       echo("

".$dir_list."

\n");


      }


     }


   }else{


    echo($dir_path."
");


   }


  }else{


   echo($dir_path."
");


  }


  Folderexp($dir_path);


}


function Getfiletype($dir){//根据扩展名显示相应的图片


 global $_GET;


 if(@$_GET['url'] !='' and is_dir(@$_GET['url'])){


  $dir = $_GET['url'].'\\'.$dir;


 }


 //print_r( $dir);


 if($dir == '' || is_null($dir) || empty($dir)){return false;}


  if(is_dir($dir)){


   return 'fold.jpg';


  }else{


   return (Getextends($dir));


  }


}

 

 

function Getextends($dir){


 if($dir =="" || is_null($dir)){return "unkown.jpg";}


  $Extends_name = substr($dir,strrpos($dir,".")+1); 


  $Extends_img = array('jpg','jpeg','gif','png','bmp','psd'); 


 if(in_array($Extends_name,$Extends_img)){return $dir;}


   switch($Extends_name){


    case "php":


     return 'image/asp_php_jsp.jpg';


     break;


    case "asp":


     return 'image/asp_php_jsp.jpg';


     break;


    case "jsp":


     return 'image/asp_php_jsp.jpg';


     break;


    case "aspx":


     return 'image/asp_php_jsp.jpg';


     break;


    case "xml":


     return 'image/asp_php_jsp.jpg';


     break;


    case "htm":


     return 'image/html_js.jpg';


     break;


    case "html":


     return 'image/html_js.jpg';


     break;


    case "shtml":


     return 'image/html_js.jpg';


     break;


    case "js":


     return 'image/html_js.jpg';


     break; 


    case "txt":


     return 'image/txt.jpg';


     break;


    case "doc":


     return 'image/word.jpg';


     break;


    default:


     return 'image/fold.jpg';


     


   }


}


function Folderexp($dir_path){//新建文件夹


  echo("

");


  echo("

");


  echo("");


  echo("

");


  echo("");


  echo("

");


  echo("

");


}


function Tool($dir_path,$lastdir){//这里显示菜单条


  echo("

");


  echo("");


  echo("");


  echo("");


  echo("");


  echo("");


  echo("");


  echo("");


  echo("");


  echo("

");


}


?>




 上一篇

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/631855.htmlTechArticle[原创]php+ajax实现模拟Win文件管理系统 //本教程由本站原创,转载请注明来处 作者:www.drise.cn 邮箱:drise@163.com QQ:271728967// 接上面我们来看dir....
Statement:
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