Heim > php教程 > php手册 > Hauptteil

PHP 读取目录 删除(可删除目录下文件)

WBOY
Freigeben: 2016-06-13 11:24:33
Original
1508 Leute haben es durchsucht

PHP 读取目录 删除(可删除目录下文件)本文章提供一款php目录管理程序,他可以对目录下的文件,文件夹,等各种文件进行管理删除操作,可以支持无限级目录的管理哦。

php教程 读取目录 删除(可删除目录下文件)
本文章提供一款php目录管理程序,他可以对目录下的文件,文件夹,等各种文件进行管理删除操作,可以支持无限级目录的管理哦。
*/

include("class.php");
$path = $_get['path'];
if($path == ""){
 $path = "dir"; 
}else{
 if(!strstr($path,"dir")){
  $path = "dir/".$path;
 }else{
  $path = $path; 
 }
}

$newdir = new dirver();
$newdir -> setpath($path);
$newdir -> dirdata();
$files = $newdir -> getfiles();
$dirs = $newdir -> getdirs();
//print_r($files);
//print_r($dirs);

echo('');
$max = 3;
$j = 0;
if(count($dirs) == 2){
echo'

';
 print("");
 print("");
 print("");
 echo '
PHP 读取目录 删除(可删除目录下文件)");
 print('');
 print($dirs[0]);
 print('
');
 print("
PHP 读取目录 删除(可删除目录下文件)");
 print('');
 print($dirs[1]);
 print('
');
 print("
");
 print("  ");
 print("
';
}else{
echo'';
while($j  print("");
 if(($j + 1) % $max == 0){
   echo '';
   if(($j + 1) != count($dirs)){
    echo '';
     }
  }
  $j++;
 }
 echo '
PHP 读取目录 删除(可删除目录下文件)");
 print('');
 print($dirs[$j]);
 print('
');
 print("
';
}
$i = 0;
if(count($files) == 2){
echo'';
 print("");
 print("");
 print("");
 echo '
PHP 读取目录 删除(可删除目录下文件) ");
 print($newdir -> change2line($files[0]));
 print("
PHP 读取目录 删除(可删除目录下文件) ");
 print($newdir -> change2line($files[1]));
 print("
");
 print("  ");
 print("
';
}else{
echo'';
while($i  print("");
 if(($i + 1) % 3 == 0){
   echo '';
   if(($i + 1) != count($files)){
    echo '';
    }
 }
 
 $i++;
}
 echo '
PHP 读取目录 删除(可删除目录下文件) ");
 print($newdir -> change2line($files[$i])); 
 print("
';
}
?>


class.php

  class for php4.x
 class  dirver{
  /class var/
  var $path;
  var $flies;
  var $dirs;
  /
  function dirver(){
   $this -> path = ""; 
   $this -> files = array();
   $this -> dirs = array();
  }
  
  function dirdata(){
   if(isset($this -> path)){
    $handle = dir($this -> path);
    while(false !== ($data = $handle -> read())){
     if(is_dir($this -> connectname($this -> path,$data)) && $data != "." && $data != ".."){
       $this -> dirs[] = $data;
       continue;
      }
      
     if($data != "." && $data != ".." && is_file($this -> connectname($this -> path,$data))){
       $this -> files[] = $data;
       continue;
      }
     
    }
    $handle -> close(); 
   }else{
    return false; 
   }
  }
  
 function setpath($src){
   if($src != ""){
    $this -> path = $src; 
   }else{
    return false; 
   }
  }
 /
 function connectname($path,$name){
  return $path."/".$name;
 }
 /
 function change2line($name){
  $basename = explode(".",$name);
  $basename = $basename[0];
  $tmp = $this -> path."/".$name;
  $tmp = ''.$basename.'';
  return $tmp; 
 }
 
 function getfiletype($file){
  if($file != ""){
   $tmp = explode(".",$file);
   $type = $tmp[count($tmp)-1];
   return $type; 
  }
 }
 
 
 function getfiles(){
  return $this -> files;
  }
 
 function getdirs(){
  return $this -> dirs; 
  }
 //
 }

?>


Verwandte Etiketten:
Quelle:php.cn
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
Beliebte Empfehlungen
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!