Last Updated on November 10, 2021 by Amit
In PHP the default value of upload_max_filesize is 2MB and the default value for post_max_size is 8MB on the server but you can increase or decrease this size limit by modifying your php.ini or . htaccess file using post_max_size and upload_max_filesize .
You can manually adjust the post data size and file size using these directives in your php.ini. See a list of supported directives you can use in php.ini .
Also see How to increase upload_max_filesize in PHP an article on tecmint.com.
post_max_size directive represents the maximum data size your form can submit to server using the POST method.
The following line in php.ini will set the maximum post size to 500mb which means that your form can submit data upto 500mb in one request.
post_max_size = "500M"
upload_max_filesize represents the maximum filesize your form can submit to server. For example if this is set as the following in your php.ini :
upload_max_filesize = "250M"
Then you can upload a file that is upto 250MB in size to server . This won’t allow you to upload files that are greater then 250MB as it’s the maximum size limit set in the directive.
You can easily increase the file upload limit on php by modifying your ini file but not all hosting service providers allow you to do that. If you can not modify your php.ini then the another easy option is to edit it via the htaccess file.
Increase php maximum upload filesize by htaccess
Since htaccess is available on all types of hosting providers, you can easily edit your htaccess file to update the PHP filesize limit.
Add the following two lines to your htaccess . You can change the size according to your needs
php_value post_max_size 100M
php_value upload_max_filesize 100M
This will set the maximum size to 100MB for both . You can change the size as per your requirements.
I hope this article was helpful. Thanks for reading it!