[HttpKernel] Fix collecting uploaded files

This commit is contained in:
Roland Franssen 2018-11-12 10:24:01 +01:00 committed by Nicolas Grekas
parent fd74951405
commit a439681bd4
2 changed files with 15 additions and 9 deletions

View File

@ -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>

View File

@ -13,6 +13,7 @@ namespace Symfony\Component\HttpKernel\DataCollector;
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 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
}
$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();