If you are building a WordPress website for your clients that you host their website in your VPS or dedicated server you may need to prevent them from uploading large images or videos to the WordPress media library when they uploading a single media file. you don’t want them to be able to upload media files larger than 2MB example.
By default, the maximum upload size in WordPress ranges from 32MB to 256MB depending on the settings of server hosting is giving by default.
To see what is the current max upload size limit allowed in the WordPress site then go to WordPress Admin dashboard → Media → Add New. the allowed max upload size will be shown as the below screenshot image (Yellow highlighted).
If the current max upload size limit doesn’t meet your demand then don’t fret, there are many ways you can reduce the max upload size in WordPress. We will be going to highlight the following ways in this article.
1- Modify php.ini through cPanel
The best way to reduce the maximum upload size in WordPress is through the website cPanel by modifying php.ini file, and here is the easiest way to do that:
- Login to website cPanel
- Go to software section
- Click on MultiPHP INI Editor
- Select the domain name
- Scroll down until you see upload_max_filesize
- Set the value you like followed with M character for Mega, in our case we set 2M.
2- Modify php.ini through upload file via FTP to WordPress root directory
The second way is to look for a php.ini file in the WordPress root directory, if php.ini file is not visible you need to create a new file instead.
1- Create a new file text editor like Notepad.
2- Copy the following code and paste it
upload_max_filesize = 25M
post_max_size = 13M
memory_limit = 15M
3- Save it as php.ini
4- Upload that php.ini file using FTP to the same root folder.
3- Edit Functions.php File
The last way to reduce the upload size limits is by adding these lines of code in the functions.php file of your theme.
@ini_set( 'upload_max_size' , '2M' );
@ini_set( 'post_max_size', '2M');
@ini_set( 'max_execution_time', '300' );
but keep in mind that if you change the WP theme then the max upload size will return to its default values until you edit the functions.php file of the new theme, because of that we recommend edit max upload via PHP.ini if it was possible.