Created
February 3, 2015 10:51
-
-
Save msankhala/87cfcf4dab1c0d438fb1 to your computer and use it in GitHub Desktop.
From http://stackoverflow.com/questions/2050859/copy-entire-contents-of-a-directory-to-another-using-php
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
<?php | |
function recurse_copy($src, $dst) { | |
$dir = opendir($src); | |
$result = ($dir === false ? false : true); | |
if ($result !== false) { | |
$result = @mkdir($dst); | |
if ($result === true) { | |
while(false !== ( $file = readdir($dir)) ) { | |
if (( $file != '.' ) && ( $file != '..' ) && $result) { | |
if ( is_dir($src . '/' . $file) ) { | |
$result = recurse_copy($src . '/' . $file,$dst . '/' . $file); | |
} else { | |
$result = copy($src . '/' . $file,$dst . '/' . $file); | |
} | |
} | |
} | |
closedir($dir); | |
} | |
} | |
return $result; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment