Techno Smarter QA

68 views Asked 01 Jul in PHP
3

I uploaded my PHP website or WordPress website to cPanel hosting, but I cannot upload large files because I am getting the upload_max_filesize limit error.

I am using cPanel or hPanel hosting, and my website works fine, but whenever I try to upload a large image, ZIP file, PDF, video, or plugin, I get an error saying that the uploaded file exceeds the maximum upload size allowed by PHP.

I have already tried changing the PHP version and editing some PHP settings, but the upload limit is still not increasing. I also contacted my hosting provider, but my problem has not been resolved.

I am using Hostinger hPanel and GoDaddy cPanel hosting.

How can I increase the upload_max_filesize limit in cPanel or hPanel?

How do I increase the PHP file upload limit for my PHP website or WordPress website?

Why am I getting the upload_max_filesize error while uploading files?

User arnabisaha (2.6K Points)

1 Answer
1
vishalrana (3.7K Points)

answered 01 Jul

I have seen the upload_max_filesize error many times while working on PHP and WordPress projects. This error usually appears when you try to upload a large file.

For example, when you upload a large WordPress theme (like a 40 MB theme), a big plugin, or import a large SQL database file in PHP, you may see this error.

This is not a coding bug. It is actually a security limit set by your hosting server. Your hosting provider allows only a specific file upload size, and you can increase that limit according to your requirements.

Whether you are using cPanel or hPanel, both hosting panels provide options to increase the upload limit. You can also change other important PHP settings like memory_limit, post_max_size, and upload_max_filesize.

If you are using Hostinger hPanel, GoDaddy cPanel, or any other cPanel hosting, and you see the upload_max_filesize error in red while uploading a file, don't worry. You can fix it easily.

There is one important thing that many developers miss.

Sometimes, they increase only the upload_max_filesize, but the error still appears. I have also made this mistake before.

The reason is that upload_max_filesize, post_max_size, and memory_limit all work together.

For example, if your memory_limit is smaller than your upload_max_filesize, increasing only the upload limit will not solve the problem. You also need to increase memory_limit and post_max_size according to the file size you want to upload.

Now let me show you how to fix this error in both cPanel and Hostinger hPanel.

How to Increase upload_max_filesize in cPanel

If you are using GoDaddy, Bluehost, HostGator, or any other hosting that provides cPanel, the steps are almost the same.

  1. Log in to your cPanel.
  2. Scroll down to the Software section.
  3. Click Select PHP Version.
  4. Open the Options tab.
  5. Scroll down until you see the PHP limits.
  6. Now change the following values:
  7. memory_limit → Set it to 256M or 512M.
  8. post_max_size → Set it to 128M.
  9. upload_max_filesize → Set it to 128M.
  10. max_execution_time → (Optional) Set it to 300 so large uploads don't time out.

In most cPanel installations, these settings are saved automatically.

Note: If your cPanel doesn't have Select PHP Version, search for MultiPHP INI Editor. Select your domain, change the same values, and click Apply.

How to Increase upload_max_filesize in Hostinger hPanel

If you've only worked with cPanel before, hPanel may look a little different, but the process is very simple.

Follow these steps:

  1. Log in to your Hostinger account.
  2. Click the Manage button for your website.
  3. In the left sidebar, click Advanced.
  4. Open PHP Configuration.
  5. Click the PHP Options tab.
  6. Now update these values:
  7. post_max_size → 128M
  8. upload_max_filesize → 128M
  9. memory_limit → 256M

Finally, click the blue Save button.

How to Increase upload_max_filesize Using the .htaccess File

If the above methods don't increase your upload limit and you're still getting the same error, you can also update the PHP limits using the .htaccess file.

This method is very simple.

  1. Open File Manager in your cPanel or hPanel.
  2. Open the public_html folder.
  3. Find the .htaccess file.
  4. If you don't see it, enable Show Hidden Files from the File Manager settings.
  5. Right-click the file and choose Edit.
  6. Add the following code at the end of the file and save it.
php_value upload_max_filesize 128M
php_value post_max_size 128M
php_value memory_limit 256M
php_value max_execution_time 300
php_value max_input_time 300

Using these methods, you can easily increase upload_max_filesize, post_max_size, memory_limit, max_execution_time, and max_input_time.

One last thing I want to mention because I've seen many developers make this mistake.

Whenever you increase the upload_max_filesize, always make sure your memory_limit is higher than the upload size.

For example, if your memory_limit is 256M and you set upload_max_filesize to 300M, you'll still get the same error because PHP doesn't have enough memory to process the upload.

In that case, increase your memory_limit to 512M (or higher if needed), and the problem should be resolved.

This small setting is often the reason why the upload_max_filesize error continues to appear even after increasing the upload limit.


Your Answer
×
Login Required

You must login to continue.

Login Login with Google
Register