I know, as explained in PHP file upload error tmp_name is empty, how to increase these values in php.ini
:
upload_max_filesize = 50M
post_max_size = 50M
However, how to enable such settings only for one site / one .php
script and not globally for all the PHP sites hosted with the same Apache server?
Is there a way to put this is a local configuration, such as .htaccess
, and not globally?
Take a look at the directives page, there's a column "Changeable". This shows how it's possible to change each setting, e.g only in php.ini, or with .htaccess or ini_set etc.
An explanation of each possible mode is here.
For both upload_max_filesize
and post_max_size
, the mode is PHP_INI_PERDIR
.
Entry can be set in php.ini, .htaccess, httpd.conf or .user.ini (since PHP 5.3)
So yes, you can use entries in .htaccess files for both:
php_value upload_max_filesize 50M
php_value post_max_size 50M