The maximum allowed size for file uploads in
PHP are defined by the
upload_max_filesize directive. As file uploads are normally done using
POST method, it is also limited by the
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
Maximum allowed size for uploaded files.
This means the actual maximum upload file size for
PHP is bound to the lowest value of both
You increase the maximum upload file size for your
PHP applications by updating your
PHP configuration file for these two directives to the values that fit your requirement and then restart your web server.
Steps to increase upload file size for PHP application:
php.inifile using your preferred text editor.
$ sudo vi /etc/php/7.4/apache2/php.ini
; Maximum allowed size for uploaded files. ; http://php.net/upload-max-filesize upload_max_filesize = 2M
upload_max_filesize = 128M
; 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
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.
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_value upload_max_filesize 128M php_value post_max_size 128M
Comment anonymously. Login not required.