While trying to figure out how to copy an entire directory to a new location (on the same web server) in php, I came across this function. I took that as a base and modified it to handle premissons better:
-
function copyr($source, $dest){
-
// Simple copy for a file
-
return $c;
-
}
-
-
// Make destination directory
-
}
-
-
// Loop through the folder
-
while (false !== $entry = $dir->read()) {
-
// Skip pointers
-
if ($entry == ‘.’ || $entry == ‘..’) {
-
continue;
-
}
-
-
// Deep copy directories
-
if ($dest !== “$source/$entryâ€) {
-
copyr(â€$source/$entryâ€, “$dest/$entryâ€);
-
}
-
}
-
-
// Clean up
-
$dir->close();
-
return true;
-
}
Ya, permissions can be a pain.