How can the copy() function in PHP be utilized for uploading files?
When uploading files in PHP, the copy() function can be utilized to move the uploaded file from the temporary directory to the desired destination folder. This function takes two parameters - the source file path and the destination file path. By using copy(), you can easily transfer the uploaded file to a permanent location on the server.
$uploadedFile = $_FILES['file']['tmp_name'];
$destination = 'uploads/' . $_FILES['file']['name'];
if (move_uploaded_file($uploadedFile, $destination)) {
echo "File uploaded successfully.";
} else {
echo "Error uploading file.";
}