What are some solutions for resolving file upload errors related to size restrictions in PHP?

When encountering file upload errors related to size restrictions in PHP, one solution is to adjust the `upload_max_filesize` and `post_max_size` directives in the php.ini file to allow for larger file uploads. Another solution is to handle the error in PHP code by checking the file size before attempting to upload it and displaying an error message to the user if it exceeds the limit.

// Check if the uploaded file size exceeds the limit
if ($_FILES['file']['size'] > 5242880) { // 5MB in bytes
    echo "Error: File size exceeds the limit of 5MB.";
} else {
    // Proceed with file upload
    move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/' . $_FILES['file']['name']);
    echo "File uploaded successfully.";
}