I have the following function which is supposed to help copy folders and files inside folders and files. I would like to copy the following source :
Documents/Projects/Sensitization Workshop Meeting/Milestones/Activity No 1/Tasks/Task One/New File.txt
To the following destination :
Documents/Projects/Sensitization Workshop Meeting/Milestones/Asqwerty/Tasks/Task One/ New File.txt
So the folder changing is Activity No 1 -> Asqwerty , I tried the following function but it didn't work :
// copy recursive
function recursive_copy($source, $dest) {
if (is_dir($source)) {
$dir_handle = opendir($source);
while ($file = readdir($dir_handle)) {
if ($file != "." && $file != "..") {
if (is_dir($source . "/" . $file)) {
if (!is_dir($dest . "/" . $file)) {
mkdir($dest . "/" . $file, 0777, TRUE);
}
$this->recurse_copy($source . '/' . $file, $dest . '/' . $file);
} else {
copy($source . "/" . $file, $dest . "/" . $file);
}
}
}
closedir($dir_handle);
} else {
copy($source, $dest);
}
}
But it only copies to the following level :
Source : Documents/Projects/Sensitization Workshop Meeting/Milestones/Activity No 1/Tasks
Destination : Documents/Projects/Sensitization Workshop Meeting/Milestones/Asqwerty/Tasks
How can I sought this out ?