Last active
September 12, 2024 13:09
-
-
Save gentritabazi/5aadc42565a809d2f288da2bf7d806a2 to your computer and use it in GitHub Desktop.
Copy all files from one folder to another folder using PHP script
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
<!-- https://stackoverflow.com/a/25780354/6055141 --> | |
function copyDirectory($source, $destination) | |
{ | |
$directory = opendir($source); | |
@mkdir($destination); | |
while (false !== ($file = readdir($directory))) { | |
if (($file != '.') && ($file != '..')) { | |
if (is_dir($source . '/' . $file)) { | |
copy_directory($source . '/' . $file, $destination . '/' . $file); | |
} else { | |
copy($source . '/' . $file, $destination . '/' . $file); | |
} | |
} | |
} | |
closedir($directory); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment