Created
June 7, 2011 14:57
-
-
Save lleitep3/1012415 to your computer and use it in GitHub Desktop.
copy a folder
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 copyDir($source,$destination) | |
{ | |
if(!is_dir($destination)) | |
mkdir($destination, 0777); | |
chmod($destination, 0777); | |
$it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source), | |
\RecursiveIteratorIterator::SELF_FIRST); | |
$it->next(); | |
while($it->valid()){ | |
if(!$it->isDot()) | |
if($it->isFile()) | |
copy($it->getRealPath(), $destination.$it->getSubPathname()); | |
else | |
mkdir($destination.$it->getSubPathname(), 0777, true); | |
$it->next(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment