0

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?

1
  • There is multiple posts about this problem. Please search by yourself before ask this kind of question Commented Sep 17, 2018 at 12:33

3 Answers 3

4

Yes, it's possible just use function ini_set, like:

ini_set('display_errors', 1);
Sign up to request clarification or add additional context in comments.

8 Comments

why cant i upload files above 2mb ? i used ini_set('upload_max_filesize', '50M');
@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.
@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/…
@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.
@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!
|
1

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)

Comments

1

You can use the function ini_set to do so.

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.