Skip to content

Commit 8540164

Browse files
authored
test: uploaded files (#5)
1 parent 87b91a2 commit 8540164

File tree

10 files changed

+838
-561
lines changed

10 files changed

+838
-561
lines changed

.github/workflows/laravel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
with:
2929
php-version: ${{ matrix.php-versions }}
3030
tools: composer:v2
31-
extensions: ctype, iconv, intl, json, mbstring, pdo, pdo_sqlite
31+
extensions: ctype, iconv, intl, json, mbstring, pdo, pdo_sqlite, fileinfo
3232
env:
3333
update: true
3434

app/Http/Controllers/TestController.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use App\Events\TestEvent;
88
use Illuminate\Http\Request;
9+
use Illuminate\Http\UploadedFile;
910

1011
final class TestController
1112
{
@@ -23,4 +24,15 @@ public function testValue(): string
2324
{
2425
return 'Test value is: ' . config('test_value');
2526
}
27+
28+
public function uploadFiles(Request $request): array
29+
{
30+
$response = [];
31+
/** @var UploadedFile $file */
32+
foreach ($request->allFiles() as $file) {
33+
$response[$file->getFilename()] = [$file->getError(), $file->isValid()];
34+
}
35+
36+
return $response;
37+
}
2638
}

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
"laravel/ui": "^3.2"
1717
},
1818
"require-dev": {
19+
"ext-fileinfo": "*",
20+
"ext-json": "*",
1921
"barryvdh/laravel-debugbar": "^3.5",
2022
"barryvdh/laravel-ide-helper": "^2.9",
2123
"codeception/codeception": "^4.1",

0 commit comments

Comments
 (0)