Can you provide an example of how to use is_uploaded_file in PHP to check for uploaded files?

When handling file uploads in PHP, it is important to validate the uploaded files to ensure they are legitimate files. One way to do this is by using the is_uploaded_file function, which checks if a file was uploaded via HTTP POST. This function can help prevent security vulnerabilities by verifying that the file was indeed uploaded through a form submission.

if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
    // Process the uploaded file
    $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.';
    }
} else {
    echo 'Invalid file upload.';
}