function FileBag::convertFileInformation
Converts uploaded files to UploadedFile instances.
Return value
UploadedFile[]|UploadedFile|null
1 call to FileBag::convertFileInformation()
- FileBag::set in vendor/
symfony/ http-foundation/ FileBag.php
File
-
vendor/
symfony/ http-foundation/ FileBag.php, line 61
Class
- FileBag
- FileBag is a container for uploaded files.
Namespace
Symfony\Component\HttpFoundationCode
protected function convertFileInformation(array|UploadedFile $file) : array|UploadedFile|null {
if ($file instanceof UploadedFile) {
return $file;
}
$file = $this->fixPhpFilesArray($file);
$keys = array_keys($file + [
'full_path' => null,
]);
sort($keys);
if (self::FILE_KEYS === $keys) {
if (\UPLOAD_ERR_NO_FILE === $file['error']) {
$file = null;
}
else {
$file = new UploadedFile($file['tmp_name'], $file['full_path'] ?? $file['name'], $file['type'], $file['error'], false);
}
}
else {
$file = array_map(fn($v) => $v instanceof UploadedFile || \is_array($v) ? $this->convertFileInformation($v) : $v, $file);
if (array_is_list($file)) {
$file = array_filter($file);
}
}
return $file;
}