Php ini upload max file size

PHP protects server performance by limiting file upload sizes, but the default limit is too low for many modern web applications. You’re likely to encounter this issue when a PHP application displays an error message asking you to increase the PHP max upload file size. There are various ways to increase the upload limit, including editing PHP configuration files directly. In this article, we’ll show you how to adjust PHP upload limits in cPanel & WHM quickly.

What Is “upload_max_filesize” in PHP?

The upload_max_filesize directive is a PHP variable set in the system and local php.ini files and user.ini files. These determine the PHP interpreter’s baseline configuration. As you might expect, upload_max_filesize limits the maximum allowable size of an uploaded file. The PHP default is 2 Megabytes, and you will have to increase it if you want to upload larger files via a PHP web application.

You may also have to adjust other directives, including:

  • post_max_size, which must be larger than upload_max_filesize.
  • memory_limit, which should be larger than post_max_size.

PHP directive values are expressed in bytes. If you set upload_max_filesize to 1000, the maximum size is 1000 bytes. However, you can also use the shorthand byte values K, M, and G for kilobytes, megabytes, and gigabytes. So, 1000K is 1000 kilobytes and 10G is 10 gigabytes.

In cPanel, you can edit PHP directives for locations and domains controlled by your account with the MultiPHP INI Editor, which you will find under Software in the main page menu.

Open the MultiPHP INI editor and select a location from the dropdown.

Php ini upload max file size

Scroll to the entry for upload_max_filesize and edit the associated value. Ensure that the value for post_max_size is larger than upload_max_filesize, and click apply at the bottom of the page.

Php ini upload max file size

How to Change the PHP Max Upload Size in WHM?

Whereas cPanel allows you to edit PHP directives in local directories, in WHM you can edit directives in the server’s main php.ini file. This affects all accounts using a particular PHP version.

To increase the PHP upload limit in WHM, open MultiPHP INI Editor from the Software section of the sidebar menu. In the dropdown, select a PHP version. PHP versions have independent configurations, so you must edit the max upload variable for all versions you wish to change.

Php ini upload max file size

Scroll to upload_max_filesize and edit the adjacent value before clicking Apply at the bottom of the page. Ensure that post_max_size is at least as large.

To learn more about editing PHP directives and what the customizable directives do, take a look at the MultiPHP INI Editor for WHM documentation.

As always, if you have any feedback or comments, please let us know. We are here to help in the best ways we can. You’ll find us on Discord, the cPanel forums, and Reddit. Be sure to also follow us on Facebook, Instagram, and Twitter.

Php ini upload max file size

WordPress is a powerhouse with many themes and plugins that allow you to build almost any website, be it an ecommerce store or a corporate network. However, when choosing WordPress hosting, you should consider performance, security, and support in the first place.

If you are building a WordPress website that hosts a portfolio with large image files or a video hosting site with a single media file size running into GBs, then you might face a roadblock of not being able to upload media files larger than 25MB (in most cases).

In this article, you will learn the maximum upload size for WordPress and how you can check and increase it with the best methods.

What Is the Maximum Upload Size for WordPress?

When building a website, you must upload different media files like images, videos, themes, plugins, etc. And uploading large files can be a hurdle if the upload file size is set to the minimum. Generally, the maximum upload size in WordPress ranges from 2MB to 150MB, depending on your web hosting settings. Your hosting provider usually sets this limit at the server level to prevent timeouts. The default upload file size on Cloudways is 10MB.

How to Check the Current Maximum Upload Size in WordPress?

To check your WordPress site’s current max upload size limit, navigate to WP Admin → Media → Add New. You will see the current max upload size on the bottom, as shown in the screenshot.

Php ini upload max file size

If the current max upload size limit meets your demand, you can leave it as it is. However, if it doesn’t, don’t fret; there are many ways you can increase the max upload size in WordPress.

These are the best methods for increasing WordPress’s maximum upload size of media files.

  1. Update .htaccess File
  2. Edit functions.php File
  3. Create or Edit php.ini File
  4. Increase Upload Size in Multisite
  5. Modify wp-config.php File
  6. Using Plugin Method
  7. Contact Hosting Provider

Increasing Your WordPress Maximum Upload File Size Is Easier With Cloudways.

Whether you’re a beginner or an expert, Cloudways Platform is based on UI, where you can make changes in a few seconds.

1. Update .htaccess File

If your web server is using Apache and PHP is set as an Apache module, then you can add a few lines of code in your WordPress .htaccess file to increase the max upload size in WordPress.

To access your .htaccess file, connect to your server via FTP client and navigate to the folder where WordPress is installed. To connect your server via FTP Client like FileZilla, you need the following values:

  • Host
  • Username
  • Password
  • Port

Php ini upload max file size

Open up the .htaccess file in a code editor or Notepad and add the following lines.

php_value upload_max_filesize 64M
php_value post_max_size 128M
php_value memory_limit 256M
php_value max_execution_time 300
php_value max_input_time 300

This will define the max upload size in Megabytes. Replace the numbers as per your requirement. The max execution time and max input time are in seconds. The execution time defines the limit of time spent on a single script. Choose a number that is suitable for your site.

2. Edit functions.php File

Sometimes, you might be unable to access your .htaccess file or be more comfortable editing WordPress theme files.

You can easily increase the size limits by adding the following lines of code in the functions.php file of your theme.  To access your functions.php file, go to WordPress Dashboard →  Appearance →  Theme File Editor and select Theme Functions file.

Php ini upload max file size

However, remember if you change the theme, the max upload size will return to its default values until you edit the functions.php file of the new theme, as the following code is added to only your current theme.

@ini_set( 'upload_max_size' , '64M' );
@ini_set( 'post_max_size', '64M');
@ini_set( 'max_execution_time', '300' );

3. Create or Edit php.ini File

This is a default file used to configure any application which runs on PHP. This file contains parameters required for file timeout, upload size, and resource limits. Access your WordPress root directory using SSH or FTP and look for a php.ini file. In some cases, this file is not visible; the other option would be to create a new file instead.

Open any text editor and create a new file on your desktop. Copy the following code and save it as php.ini.

upload_max_filesize = 64M
post_max_size = 128M
memory_limit = 264M

Php ini upload max file size

If you create a new PHP.ini file, then upload it using SSH or FTP inside the same root folder.

4. Increase Upload Size in Multisite

If you are running WordPress multisite, then upload size can be increased from settings. This increase is dependent on your server settings. If your server is set to 20MB, you cannot increase the WordPress upload size to 25MB. However, if your server is set to 20MB and your network setting is set to 15 MB, you can resolve the issue by increasing the upload size to 20MB.

Php ini upload max file size

5. Modify wp-config.php File

Another way of increasing the upload size in WordPress is to define the size parameter in the wp-config.php file. To do that, access your WordPress root directory using SSH or FTP and locate a wp-config.php file.

Php ini upload max file size

Open the file in any text editor and add the following code.

@ini_set( 'upload_max_size' , '20M' );
@ini_set( 'post_max_size', '13M');
@ini_set( 'memory_limit', '15M' );

Save your changes, and it should increase your file upload size.

6. Using Plugin Method

Not everyone is a fan of writing code or accessing root files using SSH or FTP. For that situation, the plugin comes in handy, and luckily there is a WordPress plugin available for increasing WordPress upload size. The plugin we will be using is the Increase Max Upload Filesize plugin.

Php ini upload max file size

Go to your WordPress Dashboard → Plugins → Add new, search “Increase Max Upload Filesize”, then Install and Activate the plugin. Once installed, go to plugin settings and simply enter the value for upload size.

Php ini upload max file size

Click the Save Changes button to apply the new upload size.

7. Contact Your Hosting Provider

If you do not want to edit the files, you can always contact your hosting provider to do it for you.

If you are using Cloudways WordPress managed hosting, you can easily increase the max upload size limits of all your websites on a single server through the options in the platform. It is only a matter of a few clicks, and if you are not using Cloudways, you can request a Cloudways demo to tell us your hosting challenges. Hosting plans for Cloudways involve top providers AWS, Google Compute Engine, Vultr, Linode, and DigitalOcean. With various options, no challenge is too big to overcome.

To edit the upload size limit, log in to your Cloudways account, navigate to Server under the Server Settings & Packages edit the Upload Size field as shown in the screenshot. Don’t forget to click on Save Changes at the bottom of the screen.

Php ini upload max file size

Summary

This article provides all possible solutions to increase the maximum file upload size in WordPress. However, some methods may not work on the majority of web hosts. If in case, the above methods do not work with you, the best thing to do is contact your hosting provider. Another option is simply to reduce the size or change the type of the original file – you can use the mxf converter for this. If you know any other methods that I’ve missed, please let me know in the comments.

Frequently Asked Questions

Q. How can I increase the maximum upload size through the hosting provider?

Most hosting providers usually give an option in the server configuration for increasing the maximum upload file size in WordPress. You can read the knowledge base of your hosting provider; if you don’t get the answer, contact your hosting support.

Q. Can increasing maximum upload size have an effect on site load speed?

This operation belongs to backend settings, but it can affect your site speed if your upload file is not optimized properly. It’s better if you ensure that apart from choosing the fastest WordPress hosting servers, whatever file you upload is optimized and does not make it hard for your users and search engine crawlers to load.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Customer Review at

Php ini upload max file size

“Beautifully optimized hosting for WordPress and Magento”

Arda Burak [Agency Owner]

Ahsan Parwez

Ahsan is the Community Team Manager at Cloudways - A Managed Cloud Hosting Platform. He loves to solve problems and help Cloudways' clients in any aspect he can. In his free time, you can find him playing RTS PC games.

×

Get Our Newsletter Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!

What is the maximum upload file size in PHP?

To increaes file upload size in PHP, you need to modify the upload_max_filesize and post_max_size variable's in your php. ini file. In addition, you can also set the maximum number of files allowed to be uploaded simultaneously, in a single request, using the max_file_uploads .

How do I change max upload file size in PHP?

How to Increase File Upload Size in PHP.
Open the php. ini file in the text editor..
Search for upload_max_filesize variable and specify the size which you want to increase. upload_max_filesize = 128M..
Search for post_max_size variable and specify the size which you want to increase. ( ... .
Once done, save the modified php..

How can I increase maximum upload file size?

10 Ways to Increase the Max Upload File Size in WordPress.
Contact Your Hosting Provider for Help..
Increase the Max Upload File Size in WordPress Multisite..
Update Your '.htaccess' File..
Create or Modify the 'php.ini' File..
Create or Modify the '.user.ini' File..
Change PHP Options via cPanel..

How do I change the maximum file upload size in PHP ini Ubuntu?

Ubuntu Linux Instructions.
Type "sudo nano /etc/php5/apache2/php.ini".
Press Ctrl and W and type "post_max_size".
Change the value to the number of Mb you want your site to accept as uploads..
Press Ctrl and W and type "upload_max_filesize".
Change the value to the number of Mb you want your site to accept as uploads..