diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 5e8b43d..326062f 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -67,7 +67,7 @@ public function getConfigTreeBuilder() ->end() ->scalarNode('max_size') ->defaultValue(\PHP_INT_MAX) - ->info('Set max_size to -1 for gracefully downgrade this number to the systems max upload size.') + ->info('Maximum file size in bytes. Set max_size to -1 for gracefully downgrade this number to the systems max upload size.') ->end() ->scalarNode('max_files') ->defaultValue(\PHP_INT_MAX) @@ -94,7 +94,7 @@ public function getConfigTreeBuilder() ->prototype('scalar')->end() ->end() ->scalarNode('max_size') - ->info('Set max_size to -1 for gracefully downgrade this number to the systems max upload size.') + ->info('Maximum file size in bytes. Set max_size to -1 for gracefully downgrade this number to the systems max upload size.') ->end() ->scalarNode('max_files') ->info('Set max files.') diff --git a/EventListener/MaxSizeValidationListener.php b/EventListener/MaxSizeValidationListener.php index baca1fa..6206183 100644 --- a/EventListener/MaxSizeValidationListener.php +++ b/EventListener/MaxSizeValidationListener.php @@ -30,10 +30,9 @@ public function onValidate(ValidationEvent $event) $config = $event->getConfig(); $file = $event->getFile(); - if ($file->getSize() > $config['max_size'] * (1024 * 1024)) { - $fileSizeInMegaBytes = round($file->getSize() / (1024 * 1024)); + if ($file->getSize() > $config['max_size']) { throw new ValidationException( - 'error.maxsize', ['filesize' => $fileSizeInMegaBytes, 'maxFilesize' => $config['max_size']] + 'error.maxsize', ['filesize' => $file->getSize(), 'maxFilesize' => $config['max_size']] ); } } diff --git a/Resources/translations/messages+intl-icu.en.yml b/Resources/translations/messages+intl-icu.en.yml index 50f4451..10e2244 100644 --- a/Resources/translations/messages+intl-icu.en.yml +++ b/Resources/translations/messages+intl-icu.en.yml @@ -1,3 +1,3 @@ error: invalid_type: You can't upload files of this type - maxsize: 'File is too big ({filesize} MB). Max filesize: {maxFilesize} MB' \ No newline at end of file + maxsize: 'File is too big ({filesize} bites). Max filesize: {maxFilesize} bites' \ No newline at end of file diff --git a/Resources/translations/messages+intl-icu.ru.yml b/Resources/translations/messages+intl-icu.ru.yml index c6a16bc..515d829 100644 --- a/Resources/translations/messages+intl-icu.ru.yml +++ b/Resources/translations/messages+intl-icu.ru.yml @@ -1,3 +1,3 @@ error: invalid_type: Неверный формат файла - maxsize: Файл слишком большой ({filesize} MB). Максимальный допустимый размер файла {maxFilesize} MB \ No newline at end of file + maxsize: Файл слишком большой ({filesize} байт). Максимальный допустимый размер файла {maxFilesize} байт \ No newline at end of file