What are some best practices for handling file uploads in PHP to avoid errors like "undefined index: upload"?

When handling file uploads in PHP, it is important to check if the file has been uploaded before trying to access it. This error "undefined index: upload" occurs when trying to access the uploaded file without verifying its existence first. To avoid this error, you should check if the file has been uploaded using the `isset()` function before accessing it.

if(isset($_FILES['upload'])) {
    // Access the uploaded file here
    $file = $_FILES['upload'];
    // Process the file further
} else {
    // Handle the case when no file has been uploaded
}