How can PHP be used to copy entire directories instead of just individual files for file uploads?

When uploading files in PHP, the built-in function `move_uploaded_file()` is typically used to copy individual files from a temporary directory to a specified location. To copy entire directories, you can use the `recursive` parameter in the `copy()` function along with `scandir()` to loop through all files and subdirectories within the directory.

function copyDirectory($source, $destination) {
    if (is_dir($source)) {
        @mkdir($destination);
        $directory = dir($source);
        while (false !== ($entry = $directory->read())) {
            if ($entry == '.' || $entry == '..') {
                continue;
            }
            $this->copyDirectory("$source/$entry", "$destination/$entry");
        }
        $directory->close();
    } else {
        copy($source, $destination);
    }
}

// Example usage
copyDirectory('/path/to/source_directory', '/path/to/destination_directory');