From 65e581892f40f83f817060bfe88282c99379b408 Mon Sep 17 00:00:00 2001 From: Arno Kaimbacher Date: Thu, 10 Sep 2020 16:31:30 +0200 Subject: [PATCH] - IndexController.php: create unique file names: using uuid() instead of time() --- app/Http/Controllers/Publish/IndexController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Publish/IndexController.php b/app/Http/Controllers/Publish/IndexController.php index d395729..acdfbee 100644 --- a/app/Http/Controllers/Publish/IndexController.php +++ b/app/Http/Controllers/Publish/IndexController.php @@ -22,6 +22,7 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Config; +use Illuminate\Support\Str; class IndexController extends Controller { @@ -340,7 +341,8 @@ class IndexController extends Controller $file = $uploadedFile['file']; $label = urldecode($uploadedFile['label']); $sorting = $uploadedFile['sorting']; - $fileName = "file-" . time() . '.' . $file->getClientOriginalExtension(); + // $fileName = "file-" . time() . '.' . $file->getClientOriginalExtension(); + $fileName = "file-" . Str::uuid()->toString() . '.' . $file->getClientOriginalExtension(); $mimeType = $file->getMimeType(); $datasetFolder = 'files/' . $dataset->id; $path = $file->storeAs($datasetFolder, $fileName);