-
-
Save arturosalgado/602325ec3a3743771b7200bcab697a2a 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