wordpress maximum upload file size

Increase WordPress maximum upload file size

Here are some ways on how to increase WordPress maximum upload file size

There are several ways on how to increase WordPress maximum upload file size. Please note that some of the methods require server access such as FTP, Cpanel or folder permission from the server. Otherwise, you need to ask your hosting provider to grant you an access or to increase the file upload size for you. If some of the technique does not work properly, then you need to contact your host provider to ensure that there is no settings that override these following methods.

1. Increase WordPress maximum upload file size using WordPress hook

Using the WordPress hook to increase the file upload size is the safest method as it is recommended by WordPress developers. It’s a default function of wordpress. So, why not take advantage of ‘upload_size_limit’ hook. But if your server was set lesser than the size of upload_size_limit, then the function will not take effect.

The following code goes to functions.php file of your theme folder.

<?php

add_filter( 'upload_size_limit', 'mel_upload_size_fn' );

function mel_upload_size_fn(){
  return 400 * 1024;
}

?>

The code will set the upload size to 400kb. Surely, you can increase the value by increasing the 400 up to what ever the value you require.

2. Using ini_set() a native PHP function

The function ini_set() is a native PHP function to set a value of a configuration option. Just like updating the php.ini file from the server but doing it in functions.php of your theme. But not all the available options can be changed using ini_set(). Here is the list of all available options in the appendix. Learn more about ini_set().

Paste the following code in functions.php file of your theme. In this context, the 24M means 24 megabytes. Try increasing the value to 64M if yours is not working.

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

3. Using php.ini file

This is the same as the second method but now we’re really touching the php.ini. I’m assuming that you have an access to your website folder either via FTP or Cpanel. You need to check if you already have the php.ini file first. Usually the file is already created for you. But if not found, you can just create a file called php.ini

Then, paste the following code and upload the file in the root folder of you site. It should be along with WordPress files such as wp-config.php.

img

upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300

4. Via htaccess file

Just like the 3rd method, you will need an access to your server to edit this file either FTP or Cpanel. Locate the ‘.htaccess’ file in your website root directory along with ‘wp-config.php’ file. The ‘.htaccess’ file is a hidden file. So, make sure to enable the settings to show hidden files to edit it. Edit the file and paste the following code just after you see the ‘# END WordPress’. Save the file and you’re done.

php_value upload_max_filesize 24M
php_value post_max_size 24M
php_value max_execution_time 300
php_value max_input_time 300

Check

Check by uploading a file to the media uploader in your dashboard. You can also see it written below saying ‘Maximum upload file size: 24 MB.’

wordpress maximum upload file size,Increase maximum file upload size in Wordpress,Increase file upload size,increase file upload size wordpress,increase file upload size wordpress godaddy,increase file upload size php,increase file upload size wordpress htaccess,increase file upload size drupal 8,increase file upload size in sharepoint 2013,increase file upload size htaccess,increase file upload size nginx,increase file upload size spring boot,wordpress maximum upload file size 2 mb,wordpress maximum upload file size localhost,wordpress maximum upload file size plugin,wordpress maximum upload file size 8 mb

Summary

I usually prefer the first method, I would rather update the functions.php to increase maximum file upload size in WordPress because it does not need access to the server or FTP and it gives me the ability to revert it easily. But, in some cases if the server is set to lower file upload size then I would prefer to upload a php.ini file.