简体   繁体   中英

PHP FileInfo Extension php.ini override

I'm making use of a GD Library on my application which requires me to modify my php.ini to work. I understand if I uncomment to extension=fileinfo.so the application will work as required, but my challenge is that I don't have access to my shared host server configurations. My question, Is there a way around using ini_set('', '')

Thanks ahead

Shared hosting has disabled ini_set() function for security reason if the hosting provider turn on ini_set() to you, you can have full access to php variable control, which the hosting provider don't want

for your purpose, you can do it through .htaccess file within your application root folder

two directives are permitted using .htaccess

php_flag <boolean-flag-name> on|off
php_value <flag-name> <flag-value>

php_flag should be used for on/off values

For example, the following .htaccess file will disable globals, set the maximum file upload size to 20MB, and allow PHP scripts to run for 10 minutes (600 seconds):

php_flag register_globals off
php_value upload_max_filesize 20M
php_value max_execution_time 600

You can also use ini_set function. in php scripts which allows you to change a setting within your application at runtime. The function accepts two arguments:

ini_set(flag-name, flag-value),

Example

<?php
ini_set('register_globals', 0);
ini_set('upload_max_filesize', '20M');
ini_set('max_execution_time', 600);
?>

We can query the php interpreter before changing these value to query, we can use ini_get() method

ini_get(flag-name) Returns the configuration value. I'd recommend checking your configuration change and taking appropriate action. Don't assume ini_get() will always work.

ini_get_all([extension]) Returns all configuration values as an associative array. The optional extension parameter returns options specific to that extension, eg 'allow_url_fopen'.

get_cfg_var(flag-name) Returns the original configuration value from php.ini (not any overrides set in .htaccess or by ini_set).

ini_restore(flag-name) Returns a configuration option to its original value.

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