Increasing the upload_max_filesize in WordPress

The default upload file size for WordPress is 2 MB, which is a problem if you want to upload a large media files. If you get this error, “The uploaded file exceeds the upload_max_filesize directive in php.ini”, follow these steps:

  1. Locate the php.ini file inside the wp-admin directory (if you can’t find this file see notes below)
  2. Find this line in the php.ini file “upload_max_filesize = 2M” and replace it with a higher value (e.g. “upload_max_filesize = 64M”)
  3. You may also want to increase your max post size. Look for this line in your php.ini file “post_max_size” and increase it as well.
  4. Save the changes to the file inside your wp-admin directory.
  5. Try the upload again
  6. If you still have issues, look for this file in your root directory and make the same changes.

If you don’t have a php.ini file in your directory, you can usually generate one from the control panels of your host. BlueHost has the steps listed to generate a php.ini file.

If you don’t have a php.ini file in your directory and aren’t sure where to get one (or want to see where I made the changes in the code), you can download my php.ini file. I have already increased the upload_max_filesize and the post_max_size to 64M. Once this file is copied into your wp-admin folder, the problem should be solved.

A Comment From a User

Someone left additional instructions below in the comments. I thought they were hilarious (and accurate) so I moved them up here:

@ Anyone who knows enough about their hosted files to be dangerous (ie: you crash and uncrash your site with the click of a mouse on a daily basis goofing with it), but need baby steps to do this, here goes…

First, copy the text from the developer’s PHP file listed above. (yeah, it’s long…copy all of it….no, don’t change anything. Heck, don’t even read his notes if you get intimidated easily. Really, it’s cool….just copy it as is…)

  1. Get into your files via however you do it on your host (FTP, CPanel, Legacy File Manager, whatever).
  2. Navigate to wp-admin folder. Scroll down to see if you have a php.ini file in there. I didn’t, and if you didn’t add one at some point, yours wont either.
  3. I have CPanel access, so in CPanel’s file manager, click on ‘new file’. Name it php.ini. Save it. Now, find it and check box the file name. click ‘edit’. scroll down through the ‘blah blah’ about encoding. leave the default encoding selection. click ‘edit’. a blank screen will open. right click in the box and paste the developer’s code. Click ‘save’. (if you use something else other than CPanel, adjust as necessary….for FTP, create this all in notepad on your ‘puter, name it php.ini and upload to the wp-admin folder via your fave FTP program….)
  4. Go to your wp admin panel. navigate to ‘media’. click ‘add’. voila, your new ‘limit’ will read ’64MB’. Upload something big and hold your breath. Voila….if your host doesn’t have some imposed limit, your file should be there ready to edit!
  5. IF you messed up somehow and your site breaks, don’t freak out. Just go remove the php.ini file (either by deleting it or by renaming it so it doesn’t get read). Chances are you didn’t ‘select all’ and paste it right. Start over by deleting the text from the php.ini file you just created. re-copy the developer’s text and paste it again. Give it another whirl…

About Devin

I am a developer based in Austin, Texas. I run a little theme shop called DevPress and help manage a WooCommerce shop with Universal Yums. Find me on twitter @devinsays.

184 Responses

    1. DRiX

      Elliott’s answer did me fine too. I’m also on Lunar Pages.
      I just connected to my site via FTP, then put the sample php.ini file with the memory already set worked great. BTW as far as I could tell, there was NO php.ini file in there in the first place.
      Thanx all for sharin’ yer wisdom…

  1. Jacqueline

    I am using Microsoft webmatrix, and added the phi.ini files and the WPfilebase plugin, but nothing worked…can anyone help me?

    1. Jacqueline & others having issues uploading themes or other files over 2MB to Azure – this thread provided the simplest fix I have yet found on this subject: http://social.msdn.microsoft.com/Forums/en-US/windowsazurewebsitespreview/thread/06e57c7d-187f-4468-8ab3-2fe7e28f1aa4

      The fix is:
      [1] creating a file in a text editor, calling it .user.ini
      [2] pasting this into it: upload_max_filesize = 8M
      [3] saving it and then uploading it to the root of the site [wwwroot].

      I chose the 8M over other possibilities because there are reports that 8MB is the maximum allowed on Azure Web Sites at the moment.

      Hope this helps,

      Luca

      1. Jeff Seb

        FYI: Working on a Windows machine with “Microsoft Webmatrix”. The above solution did not work by adding a php file in the wordpress directory.

        However: I found the php.ini file on the following location:
        C:\Program Files (x86)\IIS Express\PHP\v5.5\php.ini

        editing the file with the settings (I used 64M). Restarted the website and worked perfect.

        upload_max_filesize = 64M
        post_max_size = 64M

  2. eric

    worked perfect for me! just downloaded your php file (however I renamed it “php.ini” because it’s called “php.ini.ini” uploaded via cyberduck, and it worked!

    big thanks.

  3. brian

    I use ipage hosting and just put two lines in a php.ini file

    upload_max_filesize = 32M
    post_max_size = 32M

    and it works fine!

  4. rahul

    i am using 1freehosting.com wordpress
    after uploading php.ini in wp-admin folder uploadd file size
    change to 64 mb it still 8 mb

  5. Miguel

    Using WordPress 3.3.2.
    Worked like a charm creating a new php.ini in wp-admin, via the cpanel file manager, editing it and filling it up with the default php code, like suggested. Thanks!

  6. Susan Kerr

    WordPress 3.3.1 Apache on WAMP development server
    Followed instructions but kept having limit of 2M. Finally located another php.ini file here: \wamp\bin\apache\Apache2.2.21\bin.
    It had the 2M limit that must have been overriding all other settings.

  7. “First, copy the text from the developer’s PHP file listed above.”

    –How to I get the php.ini file to copy in the first place? Where is it located? I’ve been browsing through my cpanel’s file manager to no avail.
    Thanks.

  8. Joey Z

    Ftp’d the php.ini file and installed Nova theme perfectly in the required directory: wp-admin folder.

    To get php.ini file, you need to right-click on the link, then select “Save link as…”

    Thanks, to the OP!!

  9. .htaccess worked for me, php.ini did not.

    php_value upload_max_filesize  120M
    php_value post_max_size 120M
    php_value max_execution_time 200
    php_value max_input_time 200
    
    1. I did the test here locally, as friend Tim G. recommended, and it worked! First I was only testing with the first line: “php_value upload_max_filesize 120M”. It did not work well, only increased from 2MB to 8MB. I did it because I wanted to just increase the maximum size for files, thinking they were not needed 4 lines changes, only one, but I was wrong. I was curious.

  10. For GoDaddy, you will need to create a file in the root directory called “php5.ini”. Copy the code, refresh your WP Admin screen and voila, you can now upload up to 64MB! Also, note that GoDaddy allows you to increase your upload size to max 192MB. This worked like a charm. Thanks for this great info!

  11. Thanks, Devin! I seriously appreciate you working this out. I’ve been having this issue with multiple client sites. Now, I can breath easier now. I’m totally gonna spread the word.

  12. Amy

    Thanks for this! I knew how to increase the PHP memory limit in WordPress but your post helped me migrate a large blog full of content using the WordPress importer.

  13. Ian Douglas

    Tried the php.ini option and no change. The upload limit didn’t change in the Add Media option, and uploads failed. I think there is faulty syntax in your php.ini file. At least in Coda, half the file comes out in green, as if it was commented out. I don’t know enough to know where the fault is. For me, adding to the .htaccess file throws a 500 Internal Server Error

  14. Michael

    For anyone running WordPress from there own Wamp server in January 2013, here’s what worked for me. I’m a newbie though, so I have no idea otherwise…

    First of all, ignore all the above posts about uploading a php.ini file to WordPress :)

    I changed two copies of php.ini on my computer.

    There is a copy in each of these directories.

    C:\wamp\bin\apache\apache2.2.22\bin

    C:\wamp\bin\php\php5.4.3

    Restart WAMP and hopefully you’ll be good to go.

    1. Xam

      For anyone running WordPress from there own Wamp server in January 2013, here’s what worked for me. I’m a newbie though, so I have no idea otherwise…

      First of all, ignore all the above posts about uploading a php.ini file to WordPress :)

      I changed two copies of php.ini on my computer.

      There is a copy in each of these directories.

      C:\wamp\bin\apache\apache2.2.22\bin

      C:\wamp\bin\php\php5.4.3

      Restart WAMP and hopefully you’ll be good to go.

      —- how did you changed the php.ini on both directories? you just simply copy+paste it or you just change some codes?

      1. Michael

        In my case I just changed the values manually in each (though I guess they should be the same file to start with on a fresh install).

        (i.e. both values, in steps 2 and 3 –
        2. Find this line in the php.ini file “upload_max_filesize = 2M” and replace it with a higher value (e.g. “upload_max_filesize = 64M”)
        3. You may also want to increase your max post size. Look for this line in your php.ini file “post_max_size” and increase it as well.)

      2. Michael

        By the way, there are probably several places to find this info, but I used a PHP in-built function to give all the settings for my computer server setup along with the active php.ini file.

        You can easily put this one line in a PHP file e.g. name it my_phpinfo.php:

        Place this file somewhere in your www/sites directory and if in the root, for example, for a browser in Windows type localhost/my_phpinfo.php

        In my case with WAMP the “loaded configuration file” was:
        C:\wamp\bin\apache\apache2.2.22\bin\php.ini

        I just googled my solution and I found wordpress.org/support/topic/change-maximum-upload-size-and-find-phpini

        Apparently you should never keep this file accessible on a production server as you’ll be giving hackers way too much information.

  15. sophie

    The published advice from a user comment worked brilliantly for me; I created the file in cPanel as advised, then dragged the created file into my FTP program & it solved the problem in an instant! Fantastic!

  16. Pieman

    Hey, great feature this, I just uploaded the latest WordPress 3.5.1. and had this issue, I downloaded your ini file and uploaded it and it worked fine. Thanks very much.

  17. Leena

    THANK YOU!!! This error could’ve caused me a lot of problems but your article helped. I used the php.ini file and it worked a treat :D

  18. Jesse Phillips

    Can you update your post to say this only works for Apache users? Lots of time spent trying this on Microsoft Web Matrix before I read the comment that it is only for Apache. Still, thanks for helping others.

  19. Jesse Phillips

    For Windows Users see this link:
    http://wordpress.org/support/topic/where-is-this-annoying-phpini-file

    Be file to edit just the upload_max_filesize in the php file and not to overwrite the entire file with the php.ini file provided elsewhere as this might break your installation of wordpress.

    The php.ini file should be in your program files directory:
    C:\Program Files\IIS Express\PHP\v5.x\php.ini

    The “x” simply represents whatever version of PHP was installed.

    Windows by default hides system files. A *.ini file might be considered system and not show up in Windows Explorer… So go into the php folder using a command prompt window and enter:
    notepad.exe .\php.ini

    Using a phpinfo file should tell you the path to the .ini file.

    If you are not familiar with php it may then be advised to use great care in editing your php.ini file.

  20. Kate

    Wow! Thank you so much for the file and for the step-by-step instructions for the freaked out!

    Has completely solved the issue I was having.

  21. Just to say thank you for this information. A client of mine use Strato hosting, and was able to use your php file to make changes to wp media capacity.
    thank you for your help.

  22. The “A Comment From a User” worked perfectly for me :) Working on a client’s site on crazydomains which had a 2MB limit. This fixed it soooooo easily!

    THANKS~!

  23. THANK YOU!!!!!!!!!!!!!!!!!!!!!!! It worked! I have been struggling with this issue, since the first update to my theme last summer. I just gave up and lived with whatever it was that wasn’t upgraded, but when the second upgrade came, I decided I had better conquer this error. I know nothingabout PHP, etc. I just use WordPress, so most solutions were far too technical for me and my Theme provider offered no solutions. This worked and I could figure it out fairly quickly. Once again thank you!

  24. Devin! Thank you so much! I uploaded your php.ini file to my wp-admin folder and it works like a dream. Had an afternoon of contacting my host who literally said “search the internet” when i asked them if they could help me locate the php.ini file (turned out i didnt have one).
    Works like a dream and I am very thankful! I have a few items with 4 or 5 variables each so 5 variables, multiplied by 4 variables multiplied by another 5 gives a lot of options and when I was saving products half of them wouldn’t save! until now!

  25. tonyw

    This didn’t work for me, but using PLESK control panel, I could change the PHP settings. This must essentially do the same thing as a PHP.INI file on a shared server.

Leave a Reply