Skip to content

Latest commit

 

History

History
39 lines (30 loc) · 1.5 KB

increase-file-upload-size.md

File metadata and controls

39 lines (30 loc) · 1.5 KB
title updated permalink
How to Increase the File Upload Size in PHP?
August 20, 2016
/faq/how-to-increase-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 php.ini file:

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 - post_max_size and memory_limit. You will have to increase post_max_size so that it is bigger than upload_max_size.

If the value of post_max_size is set larger than memory_limit, you will have to increase also memory_limit. Recommendation is that memory_limit must always be larger than post_max_size.

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 PHP_INI_PERDIR changable. More about this is described in the manual.

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 phpinfo() function.

See Also