How to Modify the PHP Maximum Upload Size

How to Modify the PHP Maximum Upload Size

Having trouble uploading files to your WordPress site due to the size limit? If that’s the case, you’ve come to the right place. In this article, we’ll show you how to increase the size limit by modifying the PHP maximum upload size.

Why Do You Need to Change PHP Maximum Upload Size?

The standard maximum upload size in WordPress may vary depending on your hosting provider. Usually, it’s ranging from 5 to 128 MB.

Most of the time, 128 MB is enough if you only need to upload a short video or a picture. However, if you want to upload a longer video, you may need to increase the maximum upload size.

That goes double if your maximum upload size is only 5 MB. You won’t be able to install a theme or plugin, considering most plugins go beyond 5 MB these days.

On the other hand, if the size limitation is set too large, someone else may upload a large file that takes a lot of your storage. In this case, you may want to decrease the PHP maximum upload size to prevent that from happening.

How to Change the Maximum Upload Size for PHP Scripts?

In most cases, you can change the PHP maximum upload size by editing a file named php.ini. However, if you’re using Hostinger’s shared hosting plan, you don’t have access to the said file. Instead, you’re allowed to configure most of the PHP values from the .htaccess file.

  1. Navigate to the File Manager in your hPanel, open the public_html folder, and find the .htaccess file.
    Finding the .htaccess file on File Manager
  2. Open the file and insert the following codes above the #END WordPress line:
    php_value upload_max_filesize  XXM
    php_value post_max_size XXM
  3. Change the “XX” into any size you want. However, note that the post_max_size should always be larger than upload_max_filesize to avoid an error when uploading. For example, if you set the upload_max_size to 356 MB, then the post_max_size should be 357 MB or more.
  4. Once you’re done, click Save & Close.

You can also edit the .htaccess file via an FTP client like FileZilla

Checking the PHP Maximum Upload Size

After changing your PHP maximum upload size, we need to check the current size limit with the phpinfo() function to make sure that it’s already changed.

Simply create a new PHP file on the public_html directory of your WordPress site and insert the following code:

<?php

    phpinfo();

?>

You can name the file with anything you want. In this case, we name it phpinfo.php.

To access the file we just created, just ad/phpinfo.php to the end of your site’s domain (http://yoursite.com/phpinfo.php).

Checking the modified PHP maximum upload size. You’ll see two columns — local value and master value. Local value is set within the .htcaccess and overrides the master value, which is set within the php.ini. Therefore, pay no mind to the master value and seek the local value for upload_max_filesize and post_max_size instead.

If the local values of both parameters are the same as the one you set earlier, then you have successfully changed the PHP maximum upload size for your WordPress site.

Conclusion

You’ve learned how simple it is to change the PHP maximum upload size on WordPress. You can increase the limit when you’re uploading a large file or decrease it a little bit to prevent other users from taking too much space of your storage.

Why don’t you give it a try?

Author
The author

Edvinas B.

Edvinas is a professional mentor and trainer of customer support agents. When he's not teaching the secrets of providing exceptional service, he likes to travel the world and play basketball.