Created
November 19, 2015 22:14
-
-
Save gserrano/4c9648ec9eb293b9377b to your computer and use it in GitHub Desktop.
PHP Recursive copy files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This function copy $source directory and all files | |
* and sub directories to $destination folder | |
*/ | |
function recursive_copy($src,$dst) { | |
$dir = opendir($src); | |
@mkdir($dst); | |
while(( $file = readdir($dir)) ) { | |
if (( $file != '.' ) && ( $file != '..' )) { | |
if ( is_dir($src . '/' . $file) ) { | |
$this->recursive_copy($src .'/'. $file, $dst .'/'. $file); | |
} | |
else { | |
copy($src .'/'. $file,$dst .'/'. $file); | |
} | |
} | |
} | |
closedir($dir); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, thanks for the function.
There is a little typo in the body
$this->recursive_copy should be just recursive_copy
Regards