Uploading a file that exceeds the maximum file upload limit fails to upload and create an error. The maximum file upload limit depends on the hosting and the package that you are using. The maximum upload size can vary from 2 MB to 150 MB. Clearly, the maximum upload size of 2 MB is very low and is not sufficient for most of the time.
How to check the maximum upload file size
To check the maximum upload file size, go to Media > Add New to your WordPress website. You can see the current maximum upload file size on the bottom of the upload window as shown in the screenshot.
Increase the maximum upload file size
If your current maximum upload size does not meet your upload requirements, there are ways to increase the maximum file upload size. They are mainly the following:
- Edit the theme’s function.php file
- Create or edit the php.ini file
- Update .htaccess file
- Contact your hosting provider
Edit the theme’s function.php file
You can increase the maximum file upload size limits using the function.php file. On your WordPress dashboard, go to Appearances > Editor > function.php file. On a new line, add the following lines of code. Replace the memory parameter as per your requirements.
@ini_set( 'upload_max_size' , '64M' ); @ini_set( 'post_max_size', '64M'); @ini_set( 'max_execution_time', '300' );
Edit the php.ini file
If you are able to see the php.ini file in the root, then open the file in a text editor. If you are not, create a new file named php.ini. Add the following code to the file and change the values to according to your requirements. Now save and upload it to the root folder.
upload_max_filesize = 64M post_max_size = 64M max_execution_time = 300
Updating the .htaccess file
Head to the root directory and open the .htaccess file in the text editor. Adding the following code to the .htaccess file with your memory requirements can increase the maximum upload size in WordPress.
php_value upload_max_filesize 64M php_value post_max_size 64M php_value max_execution_time 300 php_value max_input_time 300
Contact your hosting provider
If the above solutions do not work for you, then the last resort is to contact your hosting provider and ask them to increase your maximum upload size limit.
nastaran
April 22, 2021
thank you for toturial
I have a question. I want to apply limits for product file uploads. is there any code for this? something like product_max_size = 64M
thanks again
Mark
April 29, 2021
Hi,
You may please change the maximum upload size to the desired value to limit the file upload size on your site.
Preshy
March 1, 2020
It worked perfectly well for me! Thanks admin for sharing this piece here. 🙏
Naijarhymes
February 25, 2020
Nice job
James Wesley
January 27, 2020
Thanks so much for sharing this amazing content. You’re awesome.
Manual
December 23, 2019
Thank you for sharing
Ifeanyi Benedict
November 25, 2019
So nice, I I love it.
Desire
November 15, 2019
Thanks for this
Midevibez
November 15, 2019
nice one
Adeyoung
May 22, 2019
I love this it helped
Adeyoung
May 22, 2019
Very helpful article
Femi Egzy
May 15, 2019
working Grade
NGSounds
April 25, 2019
Working well
ProudlyTunes
April 16, 2019
Very helpful tips
Career Kid
April 6, 2019
Thanks very much, it really works for me like a magic
T
February 13, 2019
It is the best
U.S. Custom Stickers
January 9, 2019
wow, great tip! easy enough.
Mark
January 9, 2019
Hi,
Glad that you found the article useful!
U.S. Custom Stickers
January 18, 2019
it actually was useful. however, on a side note, one site was on a managed cloud server and when we tried to update the htaccess file it would say on the hosting provider can make that change. we went into the server admin area and and made one single line change and boom! that was it. it was that easy on that one.
Cornelius N
December 17, 2018
Thanks, it worked for me