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'm a WordPress developer based in Austin, Texas. Follow my projects on GitHub, or more general WordPress ramblings as @devinsays on twitter.

151 Responses

  1. Ivain

    Thank you for your help, it worked perfectly!

    Though in my version of wordpress, the php.ini file is situated in wamp\bin\apache\apache2.2.22\bin ,that’s why some people can’t find it in their wp-amin folder (and if they try to create one, it’s overrided by the previous one existing) !

    Once again thank you for sharing!

  2. Paul

    Unfortunately I tried the new php.ini in wp-admin but am getting this error:

    “Your PHP installation appears to be missing the MySQL extension which is required by WordPress.”

    An ideas?

      1. Please try to restart your php. If you don’t have access to do that (on shared host), you could use htaccess instead of php.ini to increase upload_max_filesize, add following to .htacess
        php_value upload_max_filesize 64M
        php_value post_max_size 96

        If that still don’t work, please consult your web host. Web host may have configuration that prevent you to increase file size

  3. Hi there,
    Still at the early stages of building my website but just wanted to tell you what works for me.
    1. php.ini was nowhere to be seen in cPanel/File Manager
    2. I created a new file that I name php.ini (it’s a text file btw)
    3. I pasted the following into it :
    upload_max_filesize = 32M
    post_max_size = 32M

    4. I moved it to the root of the directory (in your home directory)
    5. Refresh and voila your upload limit should now be 32M (check in WP Admin Panel/Media/Add and you should read 32MB)

    Thanks everyone for your precious help!

    Nico.

    1. I literally spent hours on the interweb scouring for insight into this issue. It took a while for me to figure out that you meant to create a “FILE” not a “FOLDER”, but I am fairly new to this whole thing. Once I got that down everything went smoothly. Thanks, your advice was the best I could find on the net.

  4. Thank you for posting your own php.ini with the max upload already increased. I am glad to see such a well-commented file, and I wonder why it was not included in the wp-admin directory in the first place.

  5. newbie1988

    Hello everybody,

    My problem is that my php.ini file only contains the words: safe_mode = off;

    Can anybody help me? Should I create a new php.ini file?

    Would appreciate any help!

  6. Simon

    I have copied the PHP.ini file above to my wp-admin folder and wordpress root folder and done an IIS reset, still the upload remains 2mb

  7. za

    Hey, many thanks. It’s been 2 days since I got this problem. It’s solved after I download and upload your php.ini file to my wp-admin folder.

  8. Gemma

    I can’t get it to work I loaded your code into the wp-admin file using cyber duck and refreshed the server and the browser and still nothing. Am I doing something wrong?

  9. Elton

    Yeah, not getting this to work either. I copied and pasted everything from the link. I refreshed the cPanel, and nothing. Anything else to try?

  10. Mark Dionne

    After changing /etc/php.ini I needed to restart Apache before the change was honored. On my system:
    sudo service httpd restart

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>