upload-max-file-size wordpress

Solved: The uploaded file exceeds the upload_max_filesize directive in php.ini

You may have seen this error at least once, if you have used WordPress.When installing a theme, plugin or uploading a image or file, you may find this dreaded message on your screen. It has nothing to do with the theme or plugin. The issue is with your server settings which limit the maximum size for uploaded files.

It’s a common error and it can be easily fixed. This error message is an indication of that the file you are trying to upload is larger than your web host allows (WordPress default file upload size is 2 MB).

The uploaded file exceeds the upload_max_filesize directive in php.ini

Solution:

Solution is easy, you need to increase file size upload limit. You can do it yourself or ask your web host support team to increase the file size limit.

Ways you can fix it:

  1. Updating Your php.ini file
  2. Editing Your .htaccess file
  3. Editing your wp-config.php File
  4. Contact Web Hosting Support

 

solution

Updating Your php.ini file

Each server has a php.ini file, typically can be found in wp-admin folder. You need to edit open that file and write your new memory limit.

Follow these steps to edit the php.ini file

    1. Log in to your web hosting account and go to cPanel
    2. Click on FILES -> File Manager
      cPanel File Manager
    3. Select “Document Root for:” from the Directory Selection and click on Go. (Make sure the checkbox for Show Hidden Files is checked)cPanel Directory Selection
    4. Go to your wp-admin folder
    5. Find a file called php.ini or php5.ini. (If you don’t see any php.ini, create a file titled php.ini)
    6. Open the php.ini file. Find these lines in the php.ini file and replace it following numbers

  1. Save the changes you made to the php.ini file
  2. Now refresh your website and try uploading the file again.
Note: If you are using WordPress on a local machine using XAMPP, Wamp or MAMP, you will find the php.ini in following locations.
XAMPP
Windows:  C:/xampp/php/php.ini
macOS: /private/etc/php.ini
Linux: /etc/php.ini

Above settings may vary based on what web hosting company you are using. Here is list of popular webhost documentation for quick reference:

 

solution

Editing Your .htaccess file

If the above editing PHP.ini file doesn’t work for you, then you can edit your .htaccess file to fix this issue.

Follow these steps to edit your .htaccess file

    1. Log in to your web hosting account and go to cPanel
    2. Click on FILES -> File Manager
      cPanel File Manager
    3. Select “Document Root for:” from the Directory Selection and click on Go. (Make sure the checkbox for Show Hidden Files is checked)cPanel Directory Selection
    4. find the .httaccess file.
    5. Open the .htaccess file and or edit the following code at the bottom.

  1. Save the changes you made to the .htaccess file
Note: if you can’t find the .htaccess file in your root directory, create a file and name it .htaccess

 

solution

Editing your wp-config.php File

If neither of these solutions works for you, you can try editing the wp-config.php file located at your websites root folder.

    1. Log in to your web hosting account and go to cPanel
    2. Click on FILES -> File Manager
      cPanel File Manager
    3. Select “Document Root for:” from the Directory Selection and click on Go. (Make sure the checkbox for Show Hidden Files is checked)cPanel Directory Selection
    4. Add the following to the very bottom of wp-config.php

solution

Contact Web Host Support

If that none of these solutions works for you, please consult your web host. Your Web host may have configured their server in a way that prevent you to increase file size.

If you are constantly facing memory issues with your host. Try using SiteGround Hosting. We are using SiteGround for years to run our website. They are well known for their customer support & performance.

43 Comments

  1. hamedliar

    thanks….
    i’m using local host..
    editing php.ini dint work..
    but editing .htacess really works..
    once again thanks

    Reply
  2. Prakash

    Superb! It works for me…!! Great… Tnx to uploader…

    Reply
  3. Shahid

    Editing .htaccess fixed the issue. Thanks mate.

    Reply
  4. Maintenance Man

    Appreciate this – helped me work around a theme that wouldn’t upload.

    Reply
  5. Carl Viens

    Thx! I added a php.ini file as suggested and it worked fine.

    Reply
  6. Matt Young

    php.ini didn’t work, but .htaccess did for me. Thanks!

    Reply
  7. thevu

    I’m using localhost. Thank so much. You saved a lot of time for me!

    Reply
  8. Andreas

    Thank you very much for this practicial tip and the work you’ve done with it. Editing wp-config.php was my way to solve the problem! Great! Well done! Many thanks!

    Reply
  9. AT

    thanks .htaccess works with localhost.

    Reply
  10. Ibnu

    Thanks!. .htacces its work for me after i try many option from any blogs

    Reply
  11. rehalinc

    method .htaccess has worked

    Reply
  12. George

    thanks php.ini work for me

    Reply
  13. Nico

    Problem solve also with .htaccess for localhost XAMP.Thank very much. Also with php.ini does not work.
    The path for .htaccess is C:\xampp\htdocs\wordpress\.htaccess

    Reply
  14. ajazabbasi5

    thanks <3

    Reply
  15. eyeclic

    method of editing .htaccess worked. Thank you.

    Reply
  16. technoworld2017

    Thanks , Finally it worked (.htaccess)

    Reply
  17. Gimba Manasseh

    thanks a lot php.ini file edited, server restarted, problem solved

    Reply
  18. bryangoeis

    Editing the .htaccess file with Dreamweaver worked like a charm! Thank you!

    Reply
  19. Dave Nelson

    I didn’t have a php.ini file – and modifying the .htaccess file crashed the site (or just made it unloadable). So I simply followed your advice and created the php.ini file with just those lines in it, and it worked! Thank you.

    Reply
  20. Avinash Mhamle

    Nice…solve my problem ..by uploading php.in

    Reply
  21. S M Talha Moin

    .htacess really works Thanks

    Reply
  22. Umar

    thanks….
    i’m using local host..
    editing php.ini dint work..
    but copying the lines of code above and pasting at the bottom of .htacess file really works..
    once again thanks

    Reply
  23. Donald Kipsoi

    Amazing, you just solve my problem. Thank you

    Reply
  24. srihari

    Thank You for the solution

    Reply
  25. Sirisha allamneni

    Thank you vrey much. You saved my day

    Reply
  26. akbartristan

    hey, thankyou! it works men, .htaccess works with localhost.

    Reply
  27. sungmi

    THANK YOUU

    Reply
  28. Jerome Esperanza

    On local machine for example XAMPP and Wamp, you need to restart these (Apache and MySQL) after editing and saving php.ini

    Reply
  29. Hafiz Ameer Hamza

    This one also worked for me.
    Thanks

    Reply
  30. subh

    1. I am using localhost XAMPP did not found that php.ini file
    2. .htaccess file editing did the job for me

    Thanks!

    Reply
  31. Irfan Sylvanto

    well done .htaccess solve the issue

    Reply
  32. khaled El Debuch

    Thank you very much .. it’s work
    I’m use localhost
    When i change “php_value upload_max_filesize=2M” to php_value upload_max_filesize=64M” >> I could add the installing a plugin on my site.

    Reply
  33. hafidzfairiz7

    Thanks it Works 🙂

    Reply
  34. mohsin

    Thanks a lot. php.ini worked.

    Reply
  35. mauricio

    Thank you so much!! I’m a beginner and I had a very hard time trying to install a plugin. The only thing it worked for me was to editing the .htaccess file in wordpress. Thanks for your very usefull explanations!

    Reply
  36. pawan kumar

    Really work with .htaccess, Thank you

    Reply
  37. Gert Myburgh

    For those of you that said that updating your php.ini file did not work for you. Just make sure you edited/updated the correct php.ini file. If you are for example using the WAMP 64bit stack on Windows then the path will be something like ‘C:\wamp64\bin\apache\apache2.4.23\bin\php.ini’.

    Reply
  38. Gert Myburgh

    Also remember to restart your WAMP stack or whatever you are using.

    Reply
  39. ashoful

    thank you so much perfectly worked

    Reply
  40. bigolomofe

    Thank you

    Reply
  41. melvidge

    php.ini didn’t work, but .htaccess did for me. Thanks!

    Reply
  42. Ahshan Habib

    thank you so musch

    Reply
  43. hariharan

    thanks brother its working….thank u so much 🙂

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.