mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-07-29 04:31:50 +00:00
Refactored size checks for attachments and check base64 upload length
This commit is contained in:
parent
a356b94c34
commit
76a36386fc
5 changed files with 33 additions and 68 deletions
|
|
@ -65,18 +65,4 @@ class AttachmentsSettings
|
|||
envVar: "bool:ATTACHMENT_SHOW_HTML_FILES", envVarMode: EnvVarMode::OVERWRITE
|
||||
)]
|
||||
public bool $showHTMLAttachments = false;
|
||||
|
||||
public function getMaxFileSizeInMegabytes(): int
|
||||
{
|
||||
$size = $this->maxFileSize;
|
||||
$unit = strtoupper(substr($size, -1));
|
||||
$value = (int) rtrim($size, 'KMG');
|
||||
|
||||
return match ($unit) {
|
||||
'K' => (int) ceil($value / 1024),
|
||||
'M' => $value,
|
||||
'G' => $value * 1024,
|
||||
default => $value, // No unit specified, assume megabytes
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue