What are some best practices for handling file uploads in PHP to prevent issues related to size limits?

When handling file uploads in PHP, it is important to set appropriate limits on the file size to prevent issues such as running out of disk space or overwhelming the server. One way to handle this is by setting the `upload_max_filesize` and `post_max_size` directives in your php.ini configuration file to limit the size of uploaded files. Additionally, you can check the size of the uploaded file in your PHP script before processing it to ensure it does not exceed the specified limit.

// Check if the uploaded file size exceeds the limit
if ($_FILES['file']['size'] > 1000000) { // 1MB limit
    echo "File size exceeds the limit.";
    exit;
}

// Process the uploaded file
// Your file processing code here