Improve upload limit error messages

This commit is contained in:
Terranom674
2026-08-16 16:03:38 +02:00
parent 7a7f684552
commit 05798f23d0

View File

@@ -96,6 +96,18 @@ function bratonien_tools_upload_asset()
if (!isset($file['error']) || (int)$file['error'] !== UPLOAD_ERR_OK) if (!isset($file['error']) || (int)$file['error'] !== UPLOAD_ERR_OK)
{ {
$code = isset($file['error']) ? (int)$file['error'] : -1; $code = isset($file['error']) ? (int)$file['error'] : -1;
if ($code === UPLOAD_ERR_INI_SIZE)
{
throw new RuntimeException('Upload abgelehnt: Die Datei ist groesser als das PHP-Limit upload_max_filesize ('.ini_get('upload_max_filesize').').');
}
if ($code === UPLOAD_ERR_FORM_SIZE)
{
throw new RuntimeException('Upload abgelehnt: Die Datei ueberschreitet das erlaubte Upload-Limit des Formulars.');
}
if ($code === UPLOAD_ERR_PARTIAL)
{
throw new RuntimeException('Upload fehlgeschlagen: Die Datei wurde nur teilweise uebertragen.');
}
throw new RuntimeException('Upload fehlgeschlagen (PHP-Uploadcode '.$code.').'); throw new RuntimeException('Upload fehlgeschlagen (PHP-Uploadcode '.$code.').');
} }