Is upload_max_filesize
for one single file or for multiple files?
For example, if the property is set to upload_max_filesize: 5M
, is it possible to upload three single files which are 2 MB each (for a total of 6MB)? Or will that not work because upload_max_filesize
is set to 5MB?
I've been doing some tests but I would like to know the community's perspective.
Use post_max_size
to set the total and upload_max_filesize
for max per file.
Check: https://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize
upload_max_filesize
int
- The maximum size of an uploaded file. When an int is used, the value is measured in bytes. Shorthand notation, as described in this FAQ, may also be used.And https://www.php.net/manual/en/ini.core.php#ini.post-max-size
post_max_size
int
- Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize
. Generally speaking, memory_limit
should be larger than post_max_size
. When an int is used, the value is measured in bytes. Shorthand notation, as described in this FAQ, may also be used. If the size of post data is greater than post_max_size
, the $_POST
and $_FILES
superglobals are empty. This can be tracked in various ways, e.g. by passing the $_GET
variable to the script processing the data, i.e. <form action="edit.php?processed=1">
, and then checking if $_GET['processed']
is set.I can confirm that upload_max_filesize
is the maximum size per file.
e.g. with upload_max_filesize=2M
, you can upload 3 files of 1.5M
.
I just confirmed this by testing.
upload_max_filesize
(default 2M
): max size per individual file;max_file_uploads
(default 20
): max number of files you can send per request;post_max_size
(default 8M
): max raw POST data size per request;post_max_size
must be greater than the sum of the sizes of:
multipart/form-data
overhead (headers/boundaries) that wrap every single file and every single POST field in the payload.Be really careful with these limits, as PHP will not error if you exceed one of them; instead, you'll end up with partial or empty $_POST
or $_FILES
and might have a hard time debugging the issue.
For example, max_file_uploads
will silently ignore any file past the n
th uploaded file, and you'll end up with a truncated list of files with no warning whatsoever.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With