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