From 2338e22447aaff23b831bffaf7cda867988d4cf2 Mon Sep 17 00:00:00 2001 From: Fabian Schieder Date: Sun, 25 Jan 2026 23:00:54 +0100 Subject: [PATCH] Refactor target directory path handling for profile picture uploads to ensure correct leading slash --- upload.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/upload.php b/upload.php index 3662b46..512af10 100644 --- a/upload.php +++ b/upload.php @@ -64,9 +64,13 @@ $ext = $allowedMimeToExt[$mime]; // Für move_uploaded_file() brauchen wir einen Dateisystempfad; die Public-URL ist separat. $documentRoot = isset($_SERVER['DOCUMENT_ROOT']) ? (string)$_SERVER['DOCUMENT_ROOT'] : ''; $webRoot = rtrim($documentRoot, "\\/"); + +// Wichtig: relativer Zielpfad MUSS mit '/' beginnen, sonst entsteht z.B. "Websiteassets/...". +$relativeTargetDir = '/assets/images/profilePictures'; + $targetDir = $webRoot !== '' - ? $webRoot . 'assets/images/profilePictures' - : __DIR__ . 'assets/images/profilePictures'; + ? $webRoot . $relativeTargetDir + : rtrim(__DIR__, "\\/") . $relativeTargetDir; if (!is_dir($targetDir)) {