What is the difference between copy() and move_uploaded_file() functions in PHP for file uploads?

The main difference between copy() and move_uploaded_file() functions in PHP for file uploads is that copy() simply duplicates the file from the temporary directory to the destination directory, while move_uploaded_file() moves the file from the temporary directory to the destination directory and also performs additional security checks to ensure the file was uploaded via HTTP POST. To securely move an uploaded file from the temporary directory to the destination directory, it is recommended to use the move_uploaded_file() function in PHP.

if(isset($_FILES['file'])){
    $tempFile = $_FILES['file']['tmp_name'];
    $destinationFile = 'uploads/' . $_FILES['file']['name'];

    if(move_uploaded_file($tempFile, $destinationFile)){
        echo 'File uploaded successfully.';
    } else {
        echo 'Error uploading file.';
    }
}