Fix profile picture upload path by removing leading slash in directory and URL

This commit is contained in:
Fabian Schieder 2026-01-25 22:42:24 +01:00
parent 26d665f2fe
commit dde5ac9d28

View File

@ -65,8 +65,8 @@ $ext = $allowedMimeToExt[$mime];
$documentRoot = isset($_SERVER['DOCUMENT_ROOT']) ? (string)$_SERVER['DOCUMENT_ROOT'] : ''; $documentRoot = isset($_SERVER['DOCUMENT_ROOT']) ? (string)$_SERVER['DOCUMENT_ROOT'] : '';
$webRoot = rtrim($documentRoot, "\\/"); $webRoot = rtrim($documentRoot, "\\/");
$targetDir = $webRoot !== '' $targetDir = $webRoot !== ''
? $webRoot . '/assets/images/profilePictures' ? $webRoot . 'assets/images/profilePictures'
: __DIR__ . '/assets/images/profilePictures'; : __DIR__ . 'assets/images/profilePictures';
if (!is_dir($targetDir)) if (!is_dir($targetDir))
{ {
@ -102,7 +102,7 @@ if (!move_uploaded_file($tmp, $targetPath))
} }
// Pfad, der in HTML genutzt wird (URL relativ zur Webroot) // Pfad, der in HTML genutzt wird (URL relativ zur Webroot)
$publicPath = '/assets/images/profilePictures/' . $filename; $publicPath = 'assets/images/profilePictures/' . $filename;
$servername = "localhost"; $servername = "localhost";
$port = 3306; $port = 3306;