What is the role of the web server in file operations like copying in PHP?

The web server plays a crucial role in file operations like copying in PHP as it is responsible for executing the PHP code that performs the file copying. When copying files, the web server needs to have the necessary permissions to read from the source file and write to the destination file. It is important to ensure that the web server has the appropriate permissions set to perform file operations successfully.

// Copy a file using PHP
$sourceFile = 'source.txt';
$destinationFile = 'destination.txt';

if (copy($sourceFile, $destinationFile)) {
    echo "File copied successfully!";
} else {
    echo "Failed to copy file.";
}