How can one modify a PHP form mailer script to allow for uploading files larger than 2MB without any limitations?

The issue with uploading files larger than 2MB in a PHP form mailer script is typically due to the server's upload_max_filesize and post_max_size settings. To allow for larger file uploads without limitations, you can adjust these settings in your PHP configuration or override them in your script using the ini_set() function.

// Increase maximum file upload size
ini_set('upload_max_filesize', '20M');
ini_set('post_max_size', '20M');

// Process file upload
if ($_FILES['file']['error'] === UPLOAD_ERR_OK) {
    $file_name = $_FILES['file']['name'];
    $file_tmp = $_FILES['file']['tmp_name'];
    
    // Move uploaded file to desired directory
    move_uploaded_file($file_tmp, 'uploads/' . $file_name);
    
    // Add attachment to email
    $mail->addAttachment('uploads/' . $file_name);
}