-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Labels
Good first issueIdeal for your first contribution! (some Symfony experience may be required)Ideal for your first contribution! (some Symfony experience may be required)Validator
Description
Сurrent implementation for Symfony/Component/Validator/Constraints/FileValidator.php:
// ...
} elseif (preg_match('/^\d++k$/', $constraint->maxSize)) {
$size = round(filesize($path) / 1000, 2);
$limit = (int) $constraint->maxSize;
$suffix = 'kB';
} elseif (preg_match('/^\d++M$/', $constraint->maxSize)) {
$size = round(filesize($path) / 1000000, 2);
$limit = (int) $constraint->maxSize;
$suffix = 'MB';
} else {
// ...
We try upload file with size of 4 034 560 bytes (maxSize is set 4M).
It equals 3940 Kb and 3.8477 Mb.
Validation says: The file is too large (4.03 Mb). Allowed maximum size is 4 MB.
So, I think we should have following implementation for correct calculation:
- for Kb
$size = round(filesize($path) / 1024, 2);
- for Mb
$size = round(filesize($path) / 1048576, 2);
Metadata
Metadata
Assignees
Labels
Good first issueIdeal for your first contribution! (some Symfony experience may be required)Ideal for your first contribution! (some Symfony experience may be required)Validator