From 42541f56037d40ee81e5b7318107a0d60fcd1562 Mon Sep 17 00:00:00 2001 From: Troy grunt Date: Fri, 13 Feb 2026 23:12:15 +0100 Subject: [PATCH] =?UTF-8?q?pr=C3=BCfen=20was=20passiert,=20wenn=20mehrere?= =?UTF-8?q?=20dateien=20mit=20dem=20gleichen=20dateinamen=20hochgeladen=20?= =?UTF-8?q?werden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- www/admin.php | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/www/admin.php b/www/admin.php index a8d01e4..5446a96 100644 --- a/www/admin.php +++ b/www/admin.php @@ -351,8 +351,10 @@ if ($action === 'identity_edit') { if ($safeName === '') { $safeName = 'file'; } - $storedName = bin2hex(random_bytes(12)) . '_' . $safeName; - $destination = $uploadDir . $storedName; + do { + $storedName = bin2hex(random_bytes(12)) . '_' . $safeName; + $destination = $uploadDir . $storedName; + } while (is_file($destination)); if (!move_uploaded_file($tmpName, $destination)) { $fileUploadErrors[] = sprintf('Speichern von %s fehlgeschlagen.', $originalName); @@ -482,6 +484,18 @@ if ($action === 'identity_edit') { if ($identityFiles === false) { $identityFiles = []; } + $duplicateFilenameCounts = []; + foreach ($identityFiles as $file) { + $filename = $file['filename'] ?? ''; + if ($filename === '') { + continue; + } + $duplicateFilenameCounts[$filename] = ($duplicateFilenameCounts[$filename] ?? 0) + 1; + } + $duplicateFileNames = array_keys(array_filter( + $duplicateFilenameCounts, + static fn (int $count): bool => $count > 1 + )); ?> @@ -586,10 +600,18 @@ if ($action === 'identity_edit') {

+ +

+ Dateien mit identischem Dateinamen bleiben getrennt und können einzeln gelöscht. +

+