search
Homephp教程PHP源码php 文件夹与文件移动类

<script>ec(2);</script>

这是一个文件目录移动类,只要在listDir写你的要转移文件的目录名移就可以了,这个文件夹与文件移动类,比较适合采集下载的多文件操作,如要在打包文件里面加说明,等哦。

die();
 class s{
  //var $path ='flash';
  var $htm ='/index.htm';
  var $html='/index.html';
  var $ladir='/111cn.net教程';
  
  public function full_copy( $source, $target )
  {

   if ( is_dir( $source ) && $source != $source.$this->ladir )
   {
    @mkdir( $target );
    $d = dir( $source );
    while ( FALSE !== ( $entry = $d->read() ) )
    {
     if ( $entry == '.' || $entry == '..' )
     {
        continue;
     }
     $Entry = $source . '/' . $entry;
     if ( is_dir( $Entry ) )
     {
      $this->full_copy( $Entry, $target . '/' . $entry );
      continue;
     }
     copy( $Entry, $target . '/' . $entry );
    }
    $d->close();
   }
   else
   {
    copy( $source, $target );
   }
    }
   
    //
   
  public function listDir($dir_path)
  {
   if(is_dir($dir_path)){ 
    if($dir_file=opendir($dir_path)){
     while(($dir_list=readdir($dir_file))!==false)
      {
       if($dir_list!="." && $dir_list!="..")
       {        
        $this->listSunDir($dir_path."/".$dir_list);
        //$this->mkdir_r($dir_path."/".$dir_list.$this->ladir);
       }
      }
    }else{
     echo($dir_path);
    }
  }else{
 
   echo($dir_path);
  }
 }
 
 //
 
  public function listSunDir($dir_path)
  {
   if(is_dir($dir_path)){ 
    if($dir_file=opendir($dir_path)){
     while(($dir_list=readdir($dir_file))!==false)
      {
       if($dir_list!="." && $dir_list!="..")
       {
        
        //$this->mkdir_r($dir_path."/".$dir_list.$this->ladir);
        
       
        if( '/'.$dir_list == $this->ladir )
        {
         continue;
        }
        else
        {
         echo $dir_path."/".$dir_list,'
';
         $this->full_copy($dir_path."/".$dir_list,$dir_path."/".$this->ladir);
         $this->deldir($dir_path."/".$dir_list);
        }
              
        //$this->full_copy($dir_path."/".$dir_list,$dir_path."/".$dir_list.$this->ladir);
       }
      }
    }else{
     echo($dir_path);
    }
  }else{
 
   echo($dir_path);
  }
 }
 
 //
 
 public function checkFile($dir)
 {
  if( is_dir( $dir ) )
  {
   if(is_file( $dir.$htm ) || is_file($dir . $html) )
   {
     continue;
   }
   else
   {
    $this->full_copy( $dir, $target );
   }
  }
 }
 
 // mkdir
 
 function mkdir_r($dirName, $rights=0777)
 {
  $dirs = explode('/', $dirName);
  $dir='';
  foreach ($dirs as $part) {
   $dir.=$part.'/';
   if (!is_dir($dir) && strlen($dir)>0 && !is_file($dirName))
   {
    mkdir($dir, $rights);
    echo "$dirName
";
   }
  }
 }
 
 // delall
 
 function deldir($dir)
 {
  if(is_dir($dir))
  {
   $rdir = $dir;
   if($dirlist = scandir($rdir))
   {
    array_shift($dirlist);
    array_shift($dirlist);
    foreach($dirlist as $d){
     $rd = $rdir.'/'.$d;
     if(isset($d) && is_file($rd)){ 
      unlink($rd);
     }else{
      $this->deldir($rd);
     }
    }  
    rmdir($rdir);
   }else{
    return false;
   }
  }
     return true;
 }  
}

 $s = new s();
 $s->listDir('flash');//要移动目录
?>

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools