What are some best practices for handling file uploads and checking for file existence in PHP?

When handling file uploads in PHP, it is important to check for the existence of the file before attempting to upload it to prevent overwriting existing files. One way to do this is by using the `file_exists()` function to check if the file already exists in the specified directory.

// Check if file already exists
if (file_exists("uploads/" . $_FILES["file"]["name"])) {
    echo "File already exists.";
} else {
    move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]);
    echo "File uploaded successfully.";
}