Use raw bytes, not MB, when setting allowed filesize in session

This commit is contained in:
Kijin Sung 2023-11-06 08:39:15 +09:00
parent 7a659737cc
commit 426027509c
5 changed files with 10 additions and 10 deletions

View file

@ -280,7 +280,7 @@ class CommunicationView extends communication
$option->primary_key_name = 'temp_srl';
$option->content_key_name = 'content';
$option->allow_fileupload = $this->config->enable_attachment === 'Y';
$option->allowed_filesize = $this->config->attachment_size_limit ?? 0;
$option->allowed_filesize = ($this->config->attachment_size_limit ?? 0) * 1024;
$option->enable_autosave = FALSE;
$option->enable_default_component = TRUE; // FALSE;
$option->enable_component = FALSE;

View file

@ -56,7 +56,7 @@
<div class="x_control-group">
<label for="allowed_attach_size" class="x_control-label">{lang('communication.attachment_size_limit')}</label>
<div class="x_controls">
<input type="number" min="0" name="attachment_size_limit" id="attachment_size_limit" value="{$config->attachment_size_limit ?? ''}" /> MB
<input type="number" min="0" name="attachment_size_limit" id="attachment_size_limit" value="{$config->attachment_size_limit ?? ''}" /> KB
</div>
</div>
<div class="x_control-group">

View file

@ -232,8 +232,8 @@ class EditorModel extends Editor
$file_config->allowed_filesize = $file_config->allowed_filesize*1024*1024;
if (isset($option->allowed_filesize) && $option->allowed_filesize > 0)
{
$file_config->allowed_attach_size = $option->allowed_filesize * 1024 * 1024;
$file_config->allowed_filesize = $option->allowed_filesize * 1024 * 1024;
$file_config->allowed_attach_size = $option->allowed_filesize;
$file_config->allowed_filesize = $option->allowed_filesize;
}
// Calculate the appropriate chunk size.
@ -267,9 +267,9 @@ class EditorModel extends Editor
{
$upload_config['allowed_filesize'] = $option->allowed_filesize;
}
if (isset($option->allowed_filesize) && $option->allowed_filesize > 0)
if (isset($option->allowed_extensions) && !empty($option->allowed_extensions))
{
$upload_config['allowed_filesize'] = $option->allowed_filesize;
$upload_config['allowed_extensions'] = $option->allowed_extensions;
}
FileController::setUploadInfo($option->editor_sequence, $upload_target_srl, $option->module_srl ?? 0, $upload_config);

View file

@ -92,7 +92,7 @@ class FileController extends File
{
if (isset($_SESSION['upload_info'][$editor_sequence]->allowed_filesize))
{
$allowed_attach_size = $allowed_filesize = ($_SESSION['upload_info'][$editor_sequence]->allowed_filesize * 1024 * 1024);
$allowed_attach_size = $allowed_filesize = $_SESSION['upload_info'][$editor_sequence]->allowed_filesize;
}
else
{
@ -922,7 +922,7 @@ class FileController extends File
$file_size = filesize($file_info['tmp_name']);
if (isset($_SESSION['upload_info'][$editor_sequence]->allowed_filesize))
{
$allowed_attach_size = $allowed_filesize = ($_SESSION['upload_info'][$editor_sequence]->allowed_filesize * 1024 * 1024);
$allowed_attach_size = $allowed_filesize = $_SESSION['upload_info'][$editor_sequence]->allowed_filesize;
}
else
{

View file

@ -121,8 +121,8 @@ class FileModel extends File
{
if (isset($_SESSION['upload_info'][$editor_sequence]->allowed_filesize))
{
$this->add('allowed_filesize', FileHandler::filesize($_SESSION['upload_info'][$editor_sequence]->allowed_filesize * 1024 * 1024));
$this->add('allowed_attach_size', FileHandler::filesize($_SESSION['upload_info'][$editor_sequence]->allowed_filesize * 1024 * 1024));
$this->add('allowed_filesize', FileHandler::filesize($_SESSION['upload_info'][$editor_sequence]->allowed_filesize));
$this->add('allowed_attach_size', FileHandler::filesize($_SESSION['upload_info'][$editor_sequence]->allowed_filesize));
}
if (isset($_SESSION['upload_info'][$editor_sequence]->allowed_extensions))
{