Fix file upload error handling and update profile picture paths

This commit is contained in:
Fabian Schieder 2026-01-25 22:38:14 +01:00
parent 035b2272aa
commit ec53e202e1

View File

@ -29,14 +29,12 @@ if (!isset($_FILES['uploadFile']) || !is_array($_FILES['uploadFile']))
$file = $_FILES['uploadFile']; $file = $_FILES['uploadFile'];
$fileError = isset($file['error']) ? (int)$file['error'] : UPLOAD_ERR_NO_FILE; $fileError = isset($file['error']) ? (int)$file['error'] : UPLOAD_ERR_NO_FILE;
if ($fileError !== UPLOAD_ERR_OK) { if ($fileError !== UPLOAD_ERR_OK)
echo "<pre>"; {
var_dump($_FILES['uploadFile']); header('Location: account.php?upload=err');
echo "</pre>";
exit(); exit();
} }
// Basic Validierung // Basic Validierung
$tmp = isset($file['tmp_name']) ? (string)$file['tmp_name'] : ''; $tmp = isset($file['tmp_name']) ? (string)$file['tmp_name'] : '';
if ($tmp === '' || !is_uploaded_file($tmp)) if ($tmp === '' || !is_uploaded_file($tmp))
@ -62,7 +60,7 @@ if (!$mime || !isset($allowedMimeToExt[$mime]))
$ext = $allowedMimeToExt[$mime]; $ext = $allowedMimeToExt[$mime];
$targetDir = __DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'profilePictures'; $targetDir = '/FSST/Website/assets/images/profilePictures';
if (!is_dir($targetDir)) if (!is_dir($targetDir))
{ {
@mkdir($targetDir, 0755, true); @mkdir($targetDir, 0755, true);
@ -81,7 +79,7 @@ if (!move_uploaded_file($tmp, $targetPath))
} }
// Pfad, der in HTML genutzt wird (relativ zur Webroot) // Pfad, der in HTML genutzt wird (relativ zur Webroot)
$publicPath = 'assets/images/profilePictures/' . $filename; $publicPath = '/assets/images/profilePictures/' . $filename;
$servername = "localhost"; $servername = "localhost";
$port = 3306; $port = 3306;