How to increase maximum upload and PHP Memory limit in wordpress

WordPress has a modest limit for uploading images, videos, and other files. It is a similar story for your PHP memory limit. PHP memory limit helps you run plugins and scripts. If you run a website full of content sometime this could be a big problem when php limits exhausted. You may receive “Fatal error: Allowed memory size of 12345678 bytes exhausted” error.

In this article, we will show you how to increase the maximum file upload size in wordPress and increase php memory limit.

Theme Functions File:

There are cases where we have seen that just by adding the following code in the theme function file, you can increase the upload size in wordpress:

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

PHP.ini File:
In case of shared host you will not see php.ini file. Create php.ini file and add following code. Upload it in the root folder of the website

upload_max_filesize = 100M
post_max_size = 200M
memory_limit = 300M
file_uploads = On
max_execution_time = 180

htaccess File:
You have another option for increasing uploading size and increasing memory limit through htaccess file. Add following code in your htaccess file and upload root folder of the website.

php_value upload_max_filesize 64M
php_value post_max_size 200M
php_value memory_limit 300M
php_value max_execution_time 180
php_value max_input_time 180

wp-config.php File:
Try to editing wp-config file of the wordpress add the following to the very top of the file and save the file.

define( 'upload_max_size' , '64M' );
define( 'post_max_size', '64M');
define( 'max_execution_time', '300' );
define( 'WP_MEMORY_LIMIT', '96M' );