use Illuminate\Filesystem\Filesystem; $filesystem = new Filesystem(); $sourceFile = '/path/to/source/file.txt'; $destinationFile = '/path/to/destination/file.txt'; if ($filesystem->copy($sourceFile, $destinationFile)) { echo 'File copied successfully.'; } else { echo 'File copy failed.'; }
use Illuminate\Support\Facades\File; $sourceDirectory = '/path/to/source/directory'; $destinationDirectory = '/path/to/destination/directory'; File::copyDirectory($sourceDirectory, $destinationDirectory); echo 'Directory copied successfully.';This example uses the `copyDirectory` method of the Illuminate\Support\Facades\File class to copy a directory and its contents from `$sourceDirectory` to `$destinationDirectory`. If the copy operation is successful, the message "Directory copied successfully." is displayed. Both examples use the Illuminate/Filesystem package library.