Skip to content

Setting the PHP maximum upload file size in an .htaccess file

The upload_max_filesize directive in PHP defines the largest file size that can be uploaded through scripts. By default, this value is often set to 2 MB or 8 MB depending on the hosting environment. On ruachost.com, you can override this limit using a custom .htaccess file.

  • Allow larger uploads (images, videos, PDFs, backups).

  • Support CMS platforms like WordPress or Joomla that require bigger limits.

  • Prevent errors such as:

    The uploaded file exceeds the upload_max_filesize directive in php.ini.

Steps to Set upload_max_filesize in .htaccess

Section titled “Steps to Set upload_max_filesize in .htaccess”
  • Log in to cPanel or use FTP/File Manager.
  • Navigate to your site’s root directory (e.g., /public_html).
  1. If .htaccess already exists, open it for editing.
  2. If not, create a new file named .htaccess.

Insert the following lines:

php_value upload_max_filesize 64M
php_value post_max_size 64M
  • Replace 64M with the desired size (e.g., 128M).
  • Always set post_max_size equal to or larger than upload_max_filesize.
  1. Save the .htaccess file.

  2. Create a test file info.php with:

    <?php phpinfo(); ?>
  3. Load it in your browser and search for upload_max_filesize and post_max_size.

  4. Confirm the new values are active.

  5. Delete the test file afterward for security.

  • Increase gradually (e.g., 32M → 64M → 128M).
  • Adjust related directives (memory_limit, max_execution_time) for very large uploads.
  • Test uploads after making changes to ensure stability.