tags:

views:

554

answers:

3

I'm using PHP 5.3.0 and have encountered something that might be a bug (in which case I'll report it) or might be me - so I'm asking to make sure.

When running this code:

<?php
ini_set('upload_max_filesize', '10M');
echo ini_get('upload_max_filesize'), ", " , ini_get('post_max_size')

I end up with:

2M, 8M

This is despite my php.ini setting these higher:

upload_max_filesize = 10M
post_max_size = 10M

(occuring only once)

Because the error occurs after setting the value as well as it being set in php.ini I'm inclined to think it's a bug. Can anyone confirm or point me where I'm going wrong?

Update: Looks like restarting Apache fixed this - I always thought it didn't need to be restarted if you changed php.ini.

+2  A: 

Are you using a shared hosting provider? It could be master settings overriding anything you're trying to change. Have you tried adding those into your .htaccess?

php_value upload_max_filesize 10M
php_value post_max_size 10M
karim79
No, this is my own Apache/PHP instance on my machine (which is Windows if it's relevant). I'll try adding those to the Apache config.
Ross
Update: This does affect it (changes them to 10) so this method works. I'm still quite confused as to why it's not working in php.ini or using ini_set.
Ross
A: 

This can also be controlled with the apache configuration. Check the httpd.conf and/or .htaccess for something like the following:

php_value upload_max_filesize 10M
Byron Whitlock
+5  A: 

You can't use shorthand notation to set configuration values outside of PHP.ini. I assume it's falling back to 2MB as the compiled default when confronted with a bad value.

On the other hand, I didn't think upload_max_filesize could be set using ini_set(); the list at http://uk2.php.net/manual/en/ini.list.php suggests it's a PHP.ini-only setting.

Rob
You think right! You can't set upload_max_filesize using ini_set() because upload_max_filesize is a PHP_INI_PERDIR type that means changeable only via: php.ini, .htaccess or httpd.conf as stated at: http://php.net/manual/en/configuration.changes.modes.php
Marco Demajo