Just a quick question. Is there a way to change values in the php.ini using codes on the php page so that the values only change for the particular page?
3 Answers
Yes, it's possible just use function ini_set, like:
ini_set('display_errors', 1);
8 Comments
Raiyu
why cant i upload files above 2mb ? i used ini_set('upload_max_filesize', '50M');
Alex Shesterov
@Raiyu note that NOT EVERY setting can be overridden this way. Some settings are restricted by the web server (e.g. Apache) or by PHP itself.
Alex Shesterov
@Raiyu Specifically,
upload_max_filesize can't be overriden via ini_set. You can override this value in .htaccess if you use Apache. See stackoverflow.com/questions/949415/…Alex Shesterov
@Raiyu, at the moment when the PHP script runs, it's already too late to override the
upload_max_filesize value. So it's not possible to set this value from the PHP script itself. What you can do (depending on your permissions / environment): 1. edit php.ini file, 2. create/edit the .htaccess file, which is next to your root PHP script being executed or, 3. edit main Apache configuration. If nothing works: contact your hosting provider.Raiyu
@AlexShesterov Just wanted you to know that i created the .htaccess file and typed the lines and i don't understand how but it worked :D. You just saved my day my friend thanks a ton!
|
You should change that in .htaccess file
php_value upload_max_filesize 20M
php_value post_max_size 20M
http://php.net/manual/en/ini.list.php
PHP_INI_PERDIR Entry can be set in php.ini, .htaccess, httpd.conf or .user.ini (since PHP 5.3)