Jan
17
2012

Increase Max Upload File Size in WordPress

by   |  Posted in Tutorials  |  12 comments

Sometimes, you need to upload a large file to your site, and the default 8mb limit in WordPress isn’t enough. I attempted to change my limit directly on my server, then in the .htaccess file and then in wp-config.php but neither change worked for me. Then I came across this little snippet by Word Impressed which actually worked and allowed me to increase my max upload file size limit.

All you need to do is create a php.ini file and upload it into your /wp-admin folder. Then add the following:

memory_limit = 32M
upload_max_filesize = 32M
post_max_size = 32M
file_uploads = On

You can change 32m to whatever max file size you want.

About the author:

A freelance web developer living in Montreal who spends most of his time writing for this site and building Premium themes for WordPress. You can find him on Twitter @bavotasan.

Site5 Affiliate Link
If you liked this, please share it.

Tags: , , ,

Short URL: http://bit.ly/xj9K1Q

Discussion 12 Comments

  1. Joachim Kudish on January 17, 2012 at 5:07 pm

    Just a note here,

    The limit isn’t imposed by WordPress, and there isn’t a 8mb default from WordPress either. It’s completely up to the server to set the limit if any. In some cases the wp-config.php trick to increase it will work, in others the htaccess will, and in others the php.ini as you suggested will. It depends entirely on the server’s configuration and not on WordPress. So results will vary for everyone.

    • c.bavota on January 18, 2012 at 12:35 pm

      Thanks for the clarification.

    • Adam on January 19, 2012 at 5:40 pm

      I agree, Joachim. Placing a php.ini file with the above code in my /wp-admin folder didn’t have any affect. The htaccess file was my solution… and even then, I had to get my host to do some correcting on the server for this to work.

  2. Conor on January 26, 2012 at 10:49 pm

    This had been annoying me for a while and the php.ini trick worked for me. Thanks a lot!

  3. AR on January 27, 2012 at 10:26 pm

    Thanks. I also have been banging my head against the wall trying to figure this out.

  4. Web Design Preston on February 1, 2012 at 4:32 pm

    It’s defiantly worth mentioning that many hosts wont allow you to create a php.ini file if your a shared hosting. Also I’m not sure I like the idea of people being able to upload more than 8 meg. I personally cant see any genuine reason as it will only cause issues to end users.

    • c.bavota on February 2, 2012 at 11:02 am

      I needed to do this so a client could upload large PDF files but it isn’t a change that most people would want to do.

  5. Steve Wiggins on February 5, 2012 at 11:06 am

    The upload limit is set by PHP on your server to a default 8Mb. Take to code snippit above and create a text file “php.txt”. Once the file is made, change the ‘txt’ extension to ‘ini’, and uplod it to the root directory on your server – nowhere else is necessary. Many servers do not have a php.ini file in the root already, so don’t worry if you do not see one there at first. What happens, is that every time you access a PHP function, like uploading a file, PHO looks to the root directory to see if it’s defaults have been modified. If PHP sees nothing, then it runs with it’s default parameters. If it sees ‘php.ini’, it conforms to the code found there, and runs accordingly. Additionally, if your server is running php5.x.x, as many are doing nowadays, you will have to name your ‘.ini” file to ‘php5.ini’. Thank me for this, because I have never found any documentation explaining this. And you don’t have to use ‘php5.x.x.ini’, ‘php5.ini’ will work just fine. BTW, why don’t you just set the upload_max_filesize to 192Mb, while you’re at it. Same for memory, same for post. Good luck.

  6. Web Design Bournemouth on February 6, 2012 at 6:41 pm

    I host my site on a Cloud Server, when doing the mentioned it had no effect, I had to edit the main php.ini in the apache2 folder.

    But thanks for the settings, was just a mere copy and paste :P

  7. Malte Jung on February 6, 2012 at 8:53 pm

    Most Shared Hosters won’t allow their customers to change this setting. If you care about your RAM you should not set this value to high. PHP was not meant to replace FTP ;)

  8. thanh lap cong ty on February 7, 2012 at 3:09 am

    thansk ! i get error when upload a video for advertizing !

  9. Astro Gremlin on February 12, 2012 at 3:18 pm

    This article and the subsequent discussion helped clarify the issue of uploading large files. Thanks to all who contributed.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


To enter code in the comment box, please place it between <pre lang="php"> </pre> tags. You don't have to convert any characters to their hex/HTML code. Just add your code the way you would to any code editor.