How to override php.ini
This tip is for people running apache and php. I know it works with freebsd version 5.0/php 4.X/apache 2.X. I am not sure about other operating systems/webservers/php versions.
As an example scenario, A client of mine needed a php script that would allow him to upload any type of file to his server. He also wanted the default max of 4 mb to changed to 30mb. His website was being hosted on a shared server, so there was no access to php.ini. Here is how this can be done.
1) Create a file called .htaccess in the same directory as your php script (this will apply to any php script that is in this directory).
2) for each value you want to override, use the following format: php_value php_var_name php_var_value
Example:
php_value memory_limit 34M
php_value post_max_size 33M
php_value upload_max_filesize 32M
php_value max_execution_time 600
7 Comments so far
Leave a reply






Thanks! My scenario exactly.
No problem! I’m glad our articles could help you out.
Hi,
I confirm it works on Debian Sarge with PHP 5.2.1 and Apache 2.2.
Thanx for the advice!
Thanx! Had some trouble figuring out how to override upload_max_filesize until I came across your site. Keep up the good work.
Thanks for this … came in very handy!
Adnan.
this worked great
Thanks
Hii
plz let me know how to override the dynamic extension.
i want to override PDF extension. the name of the extension is :extension=php_pdf.dll
Thanks.
Sarab