The upload_max_filesize directive defines the maximum allowed size for file uploads in PHP. As file uploads are done using HTTP POST method, it is also limited by the post_max_size value. It means the actual maximum upload file size for PHP is bound to the lowest value of both post_max_size and upload_max_filesize.

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 increase your PHP application's maximum upload file size by updating both upload_max_filesize and post_max_size directives in your PHP configuration file. You can also configure the same options in the .htaccess file if you don't have administrative access to the system.

Steps to increase upload file size for PHP application:

  1. Open php.ini file using your preferred text editor.

    $ sudo vi /etc/php/7.4/apache2/php.ini
  2. Search for upload_max_filesize directive.

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

  3. Set your preferred value for upload_max_filesize.

    upload_max_filesize = 128M

  4. Search for post_max_size directive.

    ; 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 post_max_size = 8M

  5. Set your preferred value for post_max_size.

    post_max_size = 128M

    This value should be set at least as high as upload_max_filesize value. Set the value to 0 to impose no limit on the size.

  6. Restart your web server for the changes to take effect

    Alternatively, you can add the following lines in your .htaccess and the setting will apply to scripts from within the .htaccess directory without having to mess with PHP's configuration.

    php_value upload_max_filesize 128M php_value post_max_size 128M