Skip to content

Commit 61e0f83

Browse files
committed
feat: add support for multiple input files
1 parent 558bf53 commit 61e0f83

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/Request.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ public static function cookies(?string $key = null)
334334

335335
/**
336336
* Display a flash message from the previous request
337-
*
337+
*
338338
* @param string|null $key The key to get from the flash data
339339
* @return array|string|null
340340
*/
@@ -465,6 +465,22 @@ public static function upload(string $key, string $destination, array $config =
465465
return false;
466466
}
467467

468+
if (is_array($file['name'])) {
469+
$uploadedFiles = [];
470+
471+
foreach ($file['name'] as $fileKey => $image) {
472+
$uploadedFiles[] = \Leaf\FS\File::upload([
473+
'name' => $file['name'][$fileKey],
474+
'type' => $file['type'][$fileKey],
475+
'tmp_name' => $file['tmp_name'][$fileKey],
476+
'error' => $file['error'][$fileKey],
477+
'size' => $file['size'][$fileKey],
478+
], $destination, $config);
479+
}
480+
481+
return $uploadedFiles;
482+
}
483+
468484
if (isset($config['extensions'])) {
469485
$fileExtension = pathinfo($file['name'], PATHINFO_EXTENSION);
470486

0 commit comments

Comments
 (0)