Skip to content

Commit da1e4a5

Browse files
committed
Respect file_uploads ini setting
1 parent aad224b commit da1e4a5

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,8 +797,11 @@ new RequestBodyParserMiddleware(8 * 1024 * 1024); // 8 MiB limit per file
797797
```
798798

799799
By default, this middleware respects the
800+
[`file_uploads`](http://php.net/manual/en/ini.core.php#ini.file-uploads)
801+
(default `1`) and
800802
[`max_file_uploads`](http://php.net/manual/en/ini.core.php#ini.max-file-uploads)
801-
(default `20`) ini setting.
803+
(default `20`) ini settings.
804+
These settings control if any and how many files can be uploaded in a single request.
802805
If you upload more files in a single request, additional files will be ignored
803806
and the `getUploadedFiles()` method returns a truncated array.
804807
Note that upload fields left blank on submission do not count towards this limit.

src/Io/MultipartParser.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ final class MultipartParser
5757
/**
5858
* ini setting "max_file_uploads"
5959
*
60+
* Additionally, setting "file_uploads = off" effectively sets this to zero.
61+
*
6062
* @var int
6163
*/
6264
private $maxFileUploads;
@@ -81,7 +83,7 @@ public function __construct($uploadMaxFilesize = null, $maxFileUploads = null)
8183
}
8284

8385
$this->uploadMaxFilesize = $uploadMaxFilesize === null ? $this->iniUploadMaxFilesize() : (int)$uploadMaxFilesize;
84-
$this->maxFileUploads = $maxFileUploads === null ? (int)ini_get('max_file_uploads') : (int)$maxFileUploads;
86+
$this->maxFileUploads = $maxFileUploads === null ? (ini_get('file_uploads') === '' ? 0 : (int)ini_get('max_file_uploads')) : (int)$maxFileUploads;
8587
}
8688

8789
public function parse(ServerRequestInterface $request)

0 commit comments

Comments
 (0)