Increase upload file size for PHP application

Maximum upload file size for PHP is bound to the lowest value of both post_max_size and upload_max_filesize directives in your configuration. post_max_size affects maximum file upload size as file upload is normally an HTTP POST operation.

post_max_size
Maximum size of POST data that PHP will accept.
Its value may be 0 to disable the limit. It is ignored if POST data reading is disabled through enable_post_data_reading.
http://php.net/post-max-size

upload_max_filesize
Maximum allowed size for uploaded files.
http://php.net/upload-max-filesize

You can update your PHP configuration file for these two directives to the values that fit your requirement and then restart your web server.

The following example allows for file upload of not more than 200MB.

post_max_size = 200M
upload_max_filesize = 250M

Alternatively, you can add the following lines in your .htaccess and the setting will apply to scripts from within the .htaccess' directory.

php_value upload_max_filesize 200M
php_value post_max_size 250M

Restart Apache for the changes to take effect.

Sign up for Object Oriented PHP & MVC and many other great courses on Udemy to learn more.

Object Oriented PHP & MVC

Build a custom object oriented PHP MVC framework and then build an application with it!

Written by Mohd Shakir Zakaria.

Last updated on 2019-02-12.