How to Increase the File Upload Size in PHP?
Upload file size is defined in the PHP settings. Default PHP configuration values are restricted to a maximum of 2 MB upload file size.
You can increase this limit in the
memory_limit = 128M upload_max_filesize = 10M post_max_size = 12M
In above example we have increased file upload size from 2 MB to 10 MB. There are
also two additional directives -
memory_limit. You will
have to increase
post_max_size so that it is bigger than
If the value of
post_max_size is set larger than
memory_limit, you will have
to increase also
memory_limit. Recommendation is that
always be larger than
Changing ini directives can also be done by using PHP’s
ini_set() function. However this
will not work for
upload_max_filesize directive because it is
changable. More about this is described in the
Keep in mind also that there are multiple
php.ini files per PHP installation.
You can find out which ini files are loaded by executing
php --ini in your
command line or going to a PHP information page generated by the
Content of this work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license. Code snippets in examples are published under the CC0 1.0 Universal (CC0 1.0). Thanks to all the contributors.