How to Set the PHP Max Upload File Size Limit Through a .htaccess File?

This article will guide you on setting the PHP max upload file size limit through a .htaccess file. 

To set it, you need to perform the following steps – 

1. Log in to your cPanel account.

Login to cPanel account

2. Go to the Files section and click the File Manager option.

Click File Manager


3. Once you click on it, the File Manager window will be opened.

File Manager

4. Click on the Home icon, and then click on the public_html folder.



5. Select the website name on which you want to set the max PHP upload file size limit.

  • If the domain name is hosted as a primary domain name, the .htaccess file will be located under the public_html folder.
  • If the domain name is added as an addon domain, it will be located under /public_html/domain_name/. 

Here, we have added as an addon domain name so that the .htaccess will be located under /home/public_html/

Select the website name

6. Open the .htaccess file with the file editor.
If you don't see the .htaccess file in the site's document root folder, you may need to make hidden files visible or create a file.

Open .htaccess file


7. Add the following code at the end of the file. If the lines given below already exist in the file, you need to edit the value (xx) you want to set:
      php_value upload_max_filesize xxM
      php_value post_max_size xxM

Add Code


  • Replace xx with the max PHP upload file size limit you want to set in Megabytes.
  • Upload max filesize - It is the maximum size of an uploaded file; this is the limit for a single file.
  • Post max size - It is the limit of the entire request body (which may include multiple files and other stuff). The PHP documentation even says, 

"To upload large files, this value must be larger than upload_max_filesize."

If you want to set a 32 MB max PHP upload file size limit for your website, then you need to set the upload_max_filezile to 32 MB and the post_max_size to 64.

8. Click the Save changes button to save the changes made in the .htaccess file.

Save changes

9. By clicking on it, the data will be saved in the .htaccess file, and you will get a Success message on the screen.

Data Saved in .htaccess File

Following the above-listed steps will successfully set the PHP max upload file size limit through a .htaccess file.


Was this answer helpful?

« Back


/* */