NYCPHP Meetup

NYPHP.org

[nycphp-talk] ini_set problems

Dan Cech dcech at phpwerx.net
Mon Nov 26 13:13:06 EST 2007


David Krings wrote:
> I want to temporarily set much larger post, upload, and execution time
> limits for a form that is intended to upload large files (locally). I
> use the following commands:
> ini_set('upload_max_filesize', '52428800');
> ini_set('post_max_size', '53477376');
> ini_set('max_execution_time', '600');
> 
> When I follow this by a phpinfo(); I see that only the
> max_execution_time setting was updated correctly. Also, when I echo the
> retun values for each ini_set I get nothing for the first two and a 300
> for the max_execution_time (which is the correct old value). I first
> thought it was because I used shorthand for the 50M/51M limits, but even
> changing it to what is shown above doesn't make any difference.

The upload_max_filesize and post_max_size ini settings cannot be set
from within a script, because by the time your script has started any
larger uploads would have already been discarded.

You'll need to set them in .htaccess or virtual host in order for them
to have any effect.

In .htaccess, you would want something like:

# tell php to allow large uploads
php_value upload_max_filesize "16M"
php_value post_max_size "50M"
php_value max_execution_time 60
php_value max_input_time 600

# tell apache to allow large uploads
LimitRequestBody 53000000

If you want to restrict the settings to a particular script, you could
use a <Location> block.

Dan



More information about the talk mailing list