How to Restrict File Upload Size in PHP, Max Script Execution Time Using .Htaccess

Hello Friend’s I hope you are doing good, Today I am come up with one more cool .htaccess trick that is How to Restrict File Upload Size in PHP,Set Maximum Size of Post Data, Set Max Script Execution Time, Using this .htaccess hack you don’t need to change in php.ini file or any server config file, You only need to add following lines in you .htaccess files.

Restrict File Upload Size in PHP

.htaccess allows you to set file upload values that directly affect your PHP applications. For instance, if you want to impose upload limits in PHP, so that you can prevent your hosting form garbage files. just add below line in your .htaccess file.

php_value upload_max_filesize 20M

Set Maximum Size of Post Data

You can also restrict the maximum post size for uploading files in PHP, doing this add below line in your .htaccess file.

php_value post_max_size 10M

Set Maximum Script Execution Time

If you don’t want scripts to execute forever, you can limit their execution time with the help of the following line.

php_value max_execution_time 250

Thanks 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

Top