Skip to content

Commit

Permalink
Merge pull request #33 from longxinH/fix_files
Browse files Browse the repository at this point in the history
修复文件上传
  • Loading branch information
longxinH authored May 8, 2021
2 parents 10825d8 + 1daec4e commit 4f0b3e5
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/ServerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,29 +452,28 @@ public static function normalizer($files)
if (count($value) == count($value, COUNT_RECURSIVE)) {
if ($value instanceof UploadedFileInterface) {
$normalized[$key] = $value;
} elseif ( ! is_array($value['name'])) {
} elseif (isset($value['name'])) {
$normalized[$key] = UploadedFile::normalizer($value);
} elseif (is_array($value['name'])) {
$array = [];
foreach ($value['name'] as $index => $item) {
if (empty($item)) {
continue;
}
$array[] = UploadedFile::normalizer([
'name' => $value['name'][$index],
'type' => $value['type'][$index],
'tmp_name' => $value['tmp_name'][$index],
'error' => $value['error'][$index],
'size' => $value['size'][$index],
]);
}
$normalized[$key] = $array;
continue;
} else {
throw new InvalidArgumentException('Invalid value in files specification');
}
} else {
$normalized[$key] = self::normalizer($value);
$array = [];
foreach ($value['name'] as $index => $item) {
if (empty($item)) {
continue;
}

$array[] = UploadedFile::normalizer([
'name' => $value['name'][$index],
'type' => $value['type'][$index],
'tmp_name' => $value['tmp_name'][$index],
'error' => $value['error'][$index],
'size' => $value['size'][$index],
]);
}

$normalized[$key] = $array;
}
}

Expand Down

0 comments on commit 4f0b3e5

Please sign in to comment.