您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

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

2024/4/7 4:57:28发布21次查看
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($dirs[0]);
 print('');
 print( );
 print();
 print('');
 print($dirs[1]);
 print('');
 print( );
 print();
 print(  );
 print( );
 echo '
';
}else{
echo'';
while($j  print();
 print('');
 print($dirs[$j]);
 print('');
 print( );
 if(($j + 1) % $max == 0){
   echo '
';
   if(($j + 1) != count($dirs)){
    echo '';
     }
  }
  $j++;
 }
 echo '
';
}
$i = 0;
if(count($files) == 2){
echo'';
 print(%20getfiletype(%24files%5b0%5d).%22.png> );
 print($newdir -> change2line($files[0]));
 print( );
 print(%20getfiletype(%24files%5b1%5d).%22.png> );
 print($newdir -> change2line($files[1]));
 print( );
 print();
 print(  );
 print( );
 echo '
';
}else{
echo'';
while($i  print(%20getfiletype(%24files%5b%24i%5d).%22.png> );
 print($newdir -> change2line($files[$i])); 
 print( );
 if(($i + 1) % 3 == 0){
   echo '
';
   if(($i + 1) != count($files)){
    echo '';
    }
 }
$i++;
}
 echo '
';
}
?>
class.php
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; 
  }
 //
 }
?>
http://www.bkjia.com/phpjc/444856.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/444856.htmltecharticlephp 读取目录 删除(可删除目录下文件)本文章提供一款php目录管理程序,他可以对目录下的文件,文件夹,等各种文件进行管理删除操作,...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product