What are the differences between the copy() and move_uploaded_file() functions in PHP?

The main difference between the copy() and move_uploaded_file() functions in PHP is that copy() simply duplicates a file from one location to another, while move_uploaded_file() moves an uploaded file to a new location on the server. When dealing with uploaded files, it is recommended to use move_uploaded_file() as it performs additional security checks to ensure the file was uploaded via HTTP POST.

// Example of using move_uploaded_file() function
$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.';
}