<?PHP
// loc1 is the path on the computer to the base directory that may be moved
define('loc1', 'C:/Program Files/Apache Group/Apache/htdocs', true);
// copy a directory and all subdirectories and files (recursive)
// void dircpy( str 'source directory', str 'destination directory' [, bool 'overwrite existing files'] )
function dircpy($source, $dest, $overwrite = false){
if($handle = opendir(loc1 . $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(loc1 . $path)){
if(!is_file(loc1 . $dest . '/' . $file) || $overwrite)
if(!@copy(loc1 . $path, loc1 . $dest . '/' . $file)){
echo '<font color="red">File ('.$path.') could not be copied, likely a permissions problem.</font>';
}
} elseif(is_dir(loc1 . $path)){
if(!is_dir(loc1 . $dest . '/' . $file))
mkdir(loc1 . $dest . '/' . $file); // make subdirectory before subdirectory is copied
dircpy($path, $dest . '/' . $file, $overwrite); //recurse!
}
}
}
closedir($handle);
}
} // end of dircpy()
?>
Fandt det her script på PHP.net. Tror det virker.