Changing Max File and Post Size
-
This post is to provide additional information on how to change the maximum upload and post file sizes, as the information available in the forums was not effective for my self-hosted wordpress install. I’m on a CentOS 6.x server running PHP5.3
One of the sites I host had a frustrating default of 2M for the maximum file size able to be uploaded, which shows in the Media-New page. From my research, I learned that this limit is not a WordPress setting directly, but a function of the server’s PHP settings where the wordpress install is hosted. Now, I host my own site on my own server, so there’s no “turning to your host” that would help me when the advice I was finding here and on other websites wasn’t working for me. For instance, I found that the suggestions to create or edit a php.ini file in the default web root directory had no effect on the size limit for my site whatsoever. Same for the advice to edit wp-config.php, or to place the php.ini file in other places, like the wp-admin folder, or to make the web root php.ini file recursive. All those made some sense, but none actually affected my settings. And it wasn’t a global php setting, either, as I’d identified the global php path (/etc/php.ini on my server) and edited that without any effect on the resulting file and post size limits.
I was poking around some sites that were more php-specific and noted a troubleshooting tool regarding the active php configuration, though, and that cracked it all open.
First, create a file named test.php with the following code in it:
<?php phpinfo(); ?>
Upload that file to the root directory of your website (I use Filezilla, but many hosting companies may only let you upload or download files through cpanel or similar tools), then open up a browser and go to yourwebsite.com/test.php
A page should open up with your PHP version and lots of configuration information. Importantly, it tells you what php.ini file your website is using in the section helpfully called “Loaded configuration file” and where it is on the server. It’s also the most likely place that your wordpress installation is getting the max file size setting from.
You need to edit that file, and there may be many or very limited options available, depending upon how your site is hosted. I don’t allow FTP on my sever for security, but Filezilla handles SFTP. I logged in as the user for the problem website via SFTP navigated to the path were my php.ini target file was located (/home/mywebsiteusername/etc/php5/php.ini) and downloaded it for editing.
About halfway down the file, I found the two settings I wanted to change. The post_max_size setting is in the Data Handling section of my php.ini and looked like:
; Maximum size of POST data that PHP will accept. post_max_size = 2M
The File Uploads section of my php.ini file looked like:
; Whether to allow HTTP file uploads. file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). upload_tmp_dir = /home/mywebsiteusername/tmp ; Maximum allowed size for uploaded files. upload_max_filesize = 2M
I confirmed that “file_uploads” was set to On, and changed the post_max_size and upload_max_filesize settings to 64M, then saved the file and uploaded the edited file back to where I downloaded it using Filezilla, confirming that I wanted to overwrite the file. Then I restarted the server and voila! My wordpress site now shows 64M as the new, increased limit as the maximum file size able to be uploaded in the Media-New page.
After you’re done, you’ll want to delete the test.php file you uploaded, as there is a security risk to leaving it up where visitors can check out how your server is configured.
Hope this helps some of the other folks who kept following some common sense advice about changing this setting, only to find that it didn’t work for their site!
- The topic ‘Changing Max File and Post Size’ is closed to new replies.