Permalink
Browse files

bug #29183 [HttpKernel] Fix collecting uploaded files (ro0NL)

This PR was squashed before being merged into the 4.2-dev branch (closes #29183).

Discussion
----------

[HttpKernel] Fix collecting uploaded files

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #29178
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

Commits
-------

a439681 [HttpKernel] Fix collecting uploaded files
  • Loading branch information...
nicolas-grekas committed Nov 13, 2018
2 parents 6eb5f93 + a439681 commit 37785852104e31b0b6ecb5017eae42ca98fd241c
@@ -143,7 +143,7 @@
<tr>
<th scope="col">File Name</th>
<th scope="col">MIME Type</th>
<th scope="col text-right">Size (bytes)</th>
<th scope="col" class="text-right">Size (bytes)</th>
</tr>
</thead>
<tbody>
@@ -13,6 +13,7 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -58,15 +59,20 @@ public function collect(Request $request, Response $response, \Exception $except
}
$requestFiles = array();
foreach ($request->files->all() as $files) {
foreach ($files as $fileName => $fileData) {
$requestFiles[] = array(
'name' => $fileData->getClientOriginalName(),
'mimetype' => $fileData->getMimeType(),
'size' => $fileData->getSize(),
);
$extractFiles = function (array $files) use (&$extractFiles, &$requestFiles) {
foreach ($files as $file) {
if ($file instanceof UploadedFile) {
$requestFiles[] = array(
'name' => $file->getClientOriginalName(),
'mimetype' => $file->getMimeType(),
'size' => $file->getSize(),
);
} elseif (\is_array($file)) {
$extractFiles($file);
}
}
}
};
$extractFiles($request->files->all());
$sessionMetadata = array();
$sessionAttributes = array();

0 comments on commit 3778585

Please sign in to comment.