Refactor target directory path handling for profile picture uploads to ensure correct leading slash
This commit is contained in:
parent
391f9332e2
commit
2338e22447
@ -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))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user