Копиране на цяла папка в друга!

NetCutter

Registered
Имаше някъе урок за тея неща(хич не съм навътре в тях), ама нещо не мога да ги намеря :?
Затова ще помоля някой да ми каже как може да стане това.
 
LINK: http://bg.php.net/manual/en/function.copy.php

SBoisvert at Don'tSpamMe dot Bryxal dot ca каза:
to the editor's: Please pardon me.... remove my other 2 messages and this little comment and just stick this.

just a quick note to add to the great function by:bobbfwed at comcast dot net

this little version has the path not in a define but as a function parameter and also creates the destination directory if it is not already created.
Код:
<?php

  // copy a directory and all subdirectories and files (recursive)
  // void dircpy( str 'source directory', str 'destination directory' [, bool 'overwrite existing files'] )
function dircpy($basePath, $source, $dest, $overwrite = false){
   if(!is_dir($basePath . $dest)) //Lets just make sure our new folder is already created. Alright so its not efficient to check each time... bite me
   mkdir($basePath . $dest);
   if($handle = opendir($basePath . $source)){        // if the folder exploration is sucsessful, continue
       while(false !== ($file = readdir($handle))){ // as long as storing the next file to $file is successful, continue
           if($file != '.' && $file != '..'){
               $path = $source . '/' . $file;
               if(is_file($basePath . $path)){
                   if(!is_file($basePath . $dest . '/' . $file) || $overwrite)
                   if(!@copy($basePath . $path, $basePath . $dest . '/' . $file)){
                       echo '<font color="red">File ('.$path.') could not be copied, likely a permissions problem.</font>';
                   }
               } elseif(is_dir($basePath . $path)){
                   if(!is_dir($basePath . $dest . '/' . $file))
                   mkdir($basePath . $dest . '/' . $file); // make subdirectory before subdirectory is copied
                   dircpy($basePath, $path, $dest . '/' . $file, $overwrite); //recurse!
               }
           }
       }
       closedir($handle);
   }
}



?>
Това би трябвало да е :)
 

Горе