4

I'm running a WordPress site (not MU), I have set upload_max_filesize = 50M, post_max_size=50M in php.ini. The results of phpinfo() function show the value to be 50M but in WordPress Media uploader Max upload file size is still 32M.

I have also tried to write this code in the theme's functions.php:

@ini_set( 'upload_max_size' , '50M' );
@ini_set( 'post_max_size', '50M');

Also tried deactivating all plugins, changed theme but no resort, WordPress still says 32 Mb.

Can anyone guide me what can be wrong here?

2
  • did you had any luck with this? Commented May 14, 2019 at 15:39
  • Yes! Turns out the web host had applied a hard limit on these parameters. No matter what I'd do it won't go beyond 32M. I moved away from GoDaddy. Commented May 15, 2019 at 15:06

6 Answers 6

5

I had the same problem, and the other answers didn't completely work for me, and I'm apparently not alone, so here's what I did to make it work.

  1. Locate your php.ini files: sudo find / -name "php*.ini" -print. This will give you an idea of where any configuration files might be hiding.
  2. Open them one at a time (you may need sudo).
  3. Check to see if they have a line "upload_max_filesize=##" where ## is some value (i.e. 250M). You shouldn't have to add any of the lines. This should already be in the file.
  4. You will need to change the line "post_max_size=##" to be greater than or equal to upload_max_filesize.

Notes:

Supposedly, you can do "php -i | grep php.ini" to see which configuration file is being used, but changing the indicated file did not work for me. I changed one that lived at /etc/php5/apache2/php.ini to make it work. Some trial and error will be needed, but give this a shot.

Sign up to request clarification or add additional context in comments.

1 Comment

definitely the post_max_size which also need, for example when uploading themes, media etc..
4

There are many ways to achieve what you need , here are three ways you can use any one of these

1) Using functions file: Copy and paste the code below to functions.php file

@ini_set( 'upload_max_filesize' , '50M' );
@ini_set( 'post_max_size', '50M');
@ini_set( 'max_execution_time', '300' );

2) Try using htaccess method by adding the code below:

php_value upload_max_filesize 50M
php_value post_max_size 50M
php_value max_execution_time 300
php_value max_input_time 300

3) Last method, php.ini file that you are already trying

upload_max_filesize = 50M
post_max_size = 50M
max_execution_time = 300

Hope it helps !

3 Comments

Thanks for the answer. I had already tried two ways out of these 3, I tried htaccess one too but after adding that code to htaccess file the server starts throwing 500 internal server error. I believe the problem is something else, because when I rand phpinfo() function it shows the 'upload_max_filesize' value as 50.
Try adding a php.ini inside wordpress wp-admin folder. It will work.
For folks with multisite enabled, in the admin area go to My Sites -> Network Admin -> Settings and scroll down to "Max upload file size". The default for multisite caps this to 1,500KB. I changed these PHP settings in a million places before discovering THIS was what was limiting me.
4

There are a lot of people having this problem the best way to fix it is by creating a new php.ini inside your wp-admin folder.

1.Connect to your site via FTP or File Manager 2.Navigate to wp-admin folder 3.Create a file inside the wp-admin folder called php.ini 4.Add in this line: max_input_vars = 5000 5.Save

I wrote a quick blog article on it here too: Increasing Your Max_input_vars Value

2 Comments

You are correct . Adding a php.ini inside wordpress wp-admin folder worked for me.
Very interesting. Adding the file to the root did nothing. Adding it to /wp-admin/ made it work.
4

This was absolute insanity. I almost went crazy looking for a solution.

My wp-admin/php.ini was getting completely ignored.
I changed /etc/apache2/php/7.4/cli/php.ini, still nothing, it was getting ignored.
Turns out it was getting settings from /etc/php/7.4/apache2/php.ini.

Comments

2

In case you're using multisite keep in mind that there is a max_upload_filesize setting for the network.

WordPress multisite settings

Comments

0

I know it's an old post, but for any future Googlers, it's a very little known fact, but there are some settings that can not be overridden by ini_set(). The upload_max_filesize and post_max_size are 2 of those settings. A long list of the "directives" is described in the docs, and where each directive can be set.

Both these settings describe they are changeable in what they call "INI_PERDIR". From the docs ini mode constants page:

INI_PERDIR

Entry can be set in php.ini, .htaccess, httpd.conf or .user.ini

So the upload_max_filesize and post_max_size can only be set within one of these configuration files.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.