简体   繁体   中英

Increase "post_max_size" and "upload_max_filesize" only for a specific PHP file, and not for the whole server

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, eg 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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM