How to set WordPress Maximum File Upload Size

Looking to increase the default file upload size, to enable the uploading of larger than default images, documents or videos.

Don’t forget that when uploading a larger file you are likely to also need to increase the timeout allocated for the transfer.

The changes can be made via files within the website hosting space. Four files which can be amended with the settings to enable the uploading of larger files are:

  • htaccess file
  • wp-config.php file
  • php.ini
  • functions.php

Note dependant upon your host and the hosting package which you have subscribed to not all of these options will be effective. Also its possible that the host has enabled an upper cap too.

Files and Maximum Upload Settings

.htaccess File

The file .htaccess is located in the root of the website file space.

It’s used to customise the server operation to the website’s requirements.

The file may be edited either through the hosting control panel or by FTP transfer and editing locally.

Given below are the amendments to the file .htaccess to modify the WordPress maximum file upload size.

php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value memory_limit 256M
php_value max_input_time 300

wp-config.php file

This file is located at the root of the WordPress website.

To this file add the following:

@ini_set( 'upload_max_size', '64M' );
@ini_set( 'post_max_size', '64M');
@ini_set( 'memory_limit', '64M' );
@ini_set( 'max_execution_time', '300' );

Note how these entries don’t follow the pattern of define(‘key’,’value’); for most of the other entries within the wp-config.php file.

I like to keep the customisations together within the file. Typically just after the entries for the debug log file and

php.ini

This one may not work. Dependant upon your hosting package this file can be ignored.

Because it can be used to superseded the configuration of the server it is often ignored on more restrictive website hosting packages.

The file php.ini is to be located at the root of the website.

upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 256M
max_execution_time = 300

functions.php

The file is included within the active theme. At the root of its set of files.

I like the idea of this one in that enables consistency across developed themes. There becomes a predictability as to where settings have been configured.

The file maybe edited in the same way as the other files given above. And additionally often supported within WordPress is editing of the theme files, see the editor page under appearance.

Here’s its take on the addition of the three settings. For clarity its probably good to put these at the end of the file, along with your other customisations.

@ini_set('upload_max_size', '64M');
@ini_set('post_max_size', '64M');
@ini_set('max_execution_time', '300');

The Settings

memory_limit

A limit on the amount of memory which may be assigned to a script. Set this value to be greater than post_max_size.

max_execution_time

Determines how long a process can run before it is terminated. To upload large files (audio/video) the right value for this setting may need a few adjustments to get the right value

post_max_size

The maximum file size which can be used in the PHP process. Set this value to be greater than upload_max_filesize.

upload_max_filesize

Determines the maximum file size that the server will permit to be uploaded. Ensure that this value is larger than the file(s) which you wish to upload.

Further Thoughts

Given above are four different files where the settings used to increase the WordPress maximum file upload size can be incorporated.

Decide which one best suits your website and usage. Will it be .htaccess?

To see your configured Maximum file upload size click on the Media page and select to add a new item. Confirmation of the value is given below the select button, for example:

Maximum upload file size: 64 MB.

If you have increased the values to enable the uploading of a vary large file, for example an audio or video file, you may wish to lower the values once more afterwards.