FIX correctly calculate MaxFileSizeMB

The inputted value is intended to represent megabytes, but is only
multiplied by 1024 - meaning it'd represent kilobytes. This is then used
to compare with the PHP setting number, which is bytes in the range of
megabytes. Kilobytes are always under megabytes, meaning size
comparisons elsewhere in the code are always true.
We should ensure the calculation for validation is correct.
This commit is contained in:
Dylan Wagstaff 2020-11-01 11:31:23 +13:00
parent 42df67fe76
commit 0ce94b75f5

View File

@ -185,7 +185,7 @@ class EditableFileField extends EditableFormField
$result = parent::validate();
$max = static::get_php_max_file_size();
if ($this->MaxFileSizeMB * 1024 > $max) {
if ($this->MaxFileSizeMB * 1024 * 1024 > $max) {
$result->addError("Your max file size limit can't be larger than the server's limit of {$this->getPHPMaxFileSizeMB()}.");
}