Change the PHP maximum upload file size limit

Sometimes you may need to increase the maximum file size that can be uploaded to your website. This is controlled by the PHP directives upload_max_filesize and post_max_size.

⚠️ Security Tip: Avoid setting this value too high, as allowing very large file uploads can pose security and performance risks.

Increase PHP maximum upload file size using .htaccess

Method 1: Using .htaccess

  1. Log in to your cPanel and open File Manager.

  2. Locate the .htaccess file in your public_html folder.

  3. Add the following lines to the file:

    php_value upload_max_filesize 256M
    php_value post_max_size 256M
  4. Save the .htaccess file.

Note: The post_max_size value should be slightly larger than upload_max_filesize.
Example: upload_max_filesize = 100M, post_max_size = 102M.

  1. Test the changes by uploading a file in WordPress or your application.

Method 2: Using .user.ini

If your server does not allow .htaccess overrides, you can use .user.ini:

  1. Create a file named .user.ini in the public_html folder.

  2. Add the following lines:

    upload_max_filesize = 256M
    post_max_size = 256M
  3. Save the file and reload your site.

Verify the Changes Using phpinfo()

  1. Create a PHP test file (e.g., info.php) in the same directory where .htaccess or .user.ini is located.

  2. Add the following code:

    <?php
    phpinfo();
    ?>
  3. Open the test file in your browser (e.g., https://yourdomain.com/info.php).

  4. Check the values of upload_max_filesize and post_max_size to ensure your changes were applied.