Increasing the Add New Media Upload File Size Limit for WordPress

While developing and testing a new theme for WordPress locally on WAMP, a problem presented itself regarding uploading media files. In WordPress 4.4.1, the Add New Media page indicated that the maximum file size that could be uploaded had a 3M limit; however, the audio file that was being uploaded was well over the limit. The problem had nothing to do with WordPress itself, it was actually a setting in the php.ini server file that needed to be increased.

PHP.INI

Prior to finding the solution,  the upload_max_filesize in the php.ini file, was the first setting  that was changed because the research pointed to that as being the solution. However, upload_max_filesize was not set to 3M and changing the setting did not change the upload limit for adding new media in WordPress.

The post_max_size setting was set to 3M in the php.ini file. Due to the fact that post_max_size was set to 3M, the  solution to the problem uploading files larger than 3M became clear. After increasing the post_max_size, restarting all services on WAMP, as well as, reloading the Add New Media Page, the Add New Media upload file size limit was increased and the problem was finally solved.

Change the Post Max Size Limit

The following code needs to be changed in order to increase the upload size limit on the Add New Media WordPress page. The code is located in the php.ini file on the server. After updating the code with your new post_max_size limit, restart all services on the local server  WAMP, XAMP, or LAMP, reload the Add New Media page and voila!

; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size = 20M

Development Environment vs. Production Environment

Users on WAMP, XAMP, or LAMP will have access to the php.ini server file; however, if you are on a production server, you may or may not have access to the php.ini file. Therefore, if you do not have access to the php.ini file on your hosts server contact your host to have them help you solve the problem.

Post Max Size

After solving the upload file size limit dilemma, using the search term post_max_size procured many results that reiterated changing the post_max_size was the solution to the problem. It was only after figuring out the solution that it became apparent that searching for post_max_size, from the get go, would have provided the answer a lot quicker. Although the problem was solved,  why didn’t changing the upload_max_filesize setting rectify the problem? Further research regarding post_max_size led to the answer, post_max_size overrides the upload_maz_filesize setting in PHP.INI. Additionally, further research led to other pertinent information about post_max_size, as well as, other PHP settings that come into play when uploading files.

The Lowest Limit of Any Related PHP Setting Supersedes Higher Settings

In some cases related PHP settings supersede other PHP settings and the lower setting takes precedence. Therefore, the lowest setting limit of any related PHP setting supersedes a higher setting, for example:

PHP.INI – Post Max Size Overrides Max Upload Size

Here is a link for anyone interested in reading more about Post Max Size Overriding the Max Upload Size.

PHP Settings That Effect File Uploads

In addition to increasing the post_max_size setting, make sure the upload_max_filesize and max_execution_time settings are set high enough to accommodate the file size of uploads and the time it might take to process the request. Another consideration is the max_input_time, which sets the maximum time, in seconds, that the script is allowed to receive input; which includes uploading files. For large, multiple files, and or users on slower internet connections, the default of 60 seconds could easily be exceeded. (PHP.NET)

max_execution_time

; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 120

max_input_time

; Maximum amount of time each script may spend parsing request data. It's a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts.
; Note: This directive is hardcoded to -1 for the CLI SAPI
; Default Value: -1 (Unlimited)
; Development Value: 60 (60 seconds)
; Production Value: 60 (60 seconds)
; http://php.net/max-input-time
max_input_time = 60

memory_limit

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 64M

post_max_size

; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size = 3M

upload_max_filesize

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 128M