WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to write a plugin script that involves the user uploading a large file. To cope with this I need to alter the following settings:

  • post_max_size
  • upload_max_size

If I alter these in php.ini it works as intended. However, it I try the following from within my plugin code, it doesn't take affect:

@ini_set( 'upload_max_size' , '100M' );
@ini_set( 'post_max_size', '105M');

I don't really want to have to talk the user through editing of either php.ini or a WordPress config file. Ideally I'd be able to perform it for them from within the plugin.

Does anyone know how this can be achieved?


share|improve this question

First, the setting you want is 'upload_max_filesize', not 'upload_max_size'. Second, both of those settings are PHP_INI_PERDIR, which means they can only be set with php.ini, .htaccess, or httpd.conf. For more information see the PHP documentation on php.ini directives and their configuration.

I would suggest using .htaccess, personally. You might look into writing the information directly to the file from the script, just like WordPress attempts to do for rewrite rules.


I just realized that I told you to do it in .htaccess but didn't tell you how. To set those values in .htaccess add the following lines to the file (anywhere in the file):

php_value upload_max_filesize 100M
php_value post_max_size 105M
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.