Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arturosalgado/602325ec3a3743771b7200bcab697a2a to your computer and use it in GitHub Desktop.
Save arturosalgado/602325ec3a3743771b7200bcab697a2a to your computer and use it in GitHub Desktop.
PHP Recursive copy files
/*
* 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