Php.ini override on server

I have a page that allows users to upload images.

It returns a 500 error when the user tries to upload large images.

The following code ...

<?php echo ini_get("upload_max_filesize"); echo ini_get("post_max_size"); echo ini_get("max_input_time"); echo ini_get("max_execution_time"); ?> 

... returns:

 100M 100M 60 3600 

I assume this is the maximum input time that causes the problem, since I tested it with files under 100 MB, but it takes more than 60 seconds to load.

I do not have access with my host to the php.ini file, so can I override these settings? I tried adding the htaccess file, but I'm not sure if I put it in the right place.

+7
source share
2 answers

Put the .htaccess file in the root folder of your site (where is your php script) and add the following values:

 php_value upload_max_filesize 100M php_value post_max_size 100M php_value max_execution_time 200 php_value max_input_time 200 

Of course, you can set other sizes and time frames. That should work.

+15
source

The configuration of php ini directives depends on the nature of the configuration of your service provider. Run the phpinfo () script to look at your configuration. If your ISP runs PHP using suPHP in a UID user context, it can look for php.ini in the script directory. This is how it works for my hosting provider.

+1
source

All Articles