Fix #4: Logo-Upload gibt bei Fehler korrekte Fehlermeldung statt falscher Erfolgsmeldung

This commit is contained in:
fds2610 2026-03-26 12:05:00 +01:00
parent e4484d655d
commit 2516623143
4 changed files with 22 additions and 4 deletions

View file

@ -36,3 +36,9 @@ RUN mkdir -p /var/www/html/public/static/uploads /var/www/html/data \
&& chmod -R 755 /var/www/html/data && chmod -R 755 /var/www/html/data
EXPOSE 80 EXPOSE 80
# Ensure upload directory has correct ownership at runtime (covers named volume mounts)
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["apache2-foreground"]

4
docker-entrypoint.sh Normal file
View file

@ -0,0 +1,4 @@
#!/bin/sh
# Fix ownership of volume-mounted upload directory at container start
chown -R www-data:www-data /var/www/html/public/static/uploads 2>/dev/null || true
exec "$@"

View file

@ -73,9 +73,17 @@ class SettingsController
$relPath = 'static/uploads/logo/logo.' . $ext; $relPath = 'static/uploads/logo/logo.' . $ext;
$absDir = dirname(__DIR__, 2) . '/public/static/uploads/logo'; $absDir = dirname(__DIR__, 2) . '/public/static/uploads/logo';
if (!is_dir($absDir)) mkdir($absDir, 0755, true); if (!is_dir($absDir) && !mkdir($absDir, 0755, true)) {
View::redirect('/settings', 'Upload-Verzeichnis konnte nicht erstellt werden.', 'error');
return;
}
$dest = dirname(__DIR__, 2) . '/public/' . $relPath;
if (!move_uploaded_file($file['tmp_name'], $dest)) {
View::redirect('/settings', 'Datei konnte nicht gespeichert werden. Bitte Schreibrechte prüfen.', 'error');
return;
}
move_uploaded_file($file['tmp_name'], dirname(__DIR__, 2) . '/public/' . $relPath);
Setting::setLogo($relPath); Setting::setLogo($relPath);
View::redirect('/settings', 'Logo hochgeladen.'); View::redirect('/settings', 'Logo hochgeladen.');

View file

@ -159,8 +159,8 @@
<?php endif; ?> <?php endif; ?>
<form method="post" action="/settings/logo" enctype="multipart/form-data"> <form method="post" action="/settings/logo" enctype="multipart/form-data">
<div class="form-group"> <div class="form-group">
<label>Logo hochladen (PNG, JPG, SVG)</label> <label>Logo hochladen (PNG, JPG)</label>
<input type="file" name="logo" accept=".png,.jpg,.jpeg,.svg"> <input type="file" name="logo" accept=".png,.jpg,.jpeg">
<div class="form-hint">Empfohlen: transparentes PNG, mind. 300px breit</div> <div class="form-hint">Empfohlen: transparentes PNG, mind. 300px breit</div>
</div> </div>
<button type="submit" class="btn btn-secondary">Logo hochladen</button> <button type="submit" class="btn btn-secondary">Logo hochladen</button>