whenpenguinsattack.com

Friday, January 20, 2006

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

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home