8000 validation of upload_max_filesize · Issue #32479 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
validation of upload_max_filesize #32479
Closed
@kernig

Description

@kernig

Symfony version(s) affected: seems to be in every version since an old 2.x. I did use 3.4

Description
Not sure if this is a bug or should be a feature request.
The validation(function normalizeBinaryFormat) in symfony/src/Symfony/Component/Validator/Constraints/File.php doesn't work with gigabyte values in php.ini.
In the PHP documentation it says "PHP allows shortcuts for byte values, including K (kilo), M (mega) and G (giga). " so in my opinion these values should work.

How to reproduce
Set upload_max_filesize in php.ini to 1G. I noticed this problem in prestashop, but you can just call this function to get the error.

Possible Solution
I found a fix on this website:
https://kijam.com/tienda/reparar-error-1g-is-not-a-valid-maximun-size-en-prestashop-1-7/

Quote:
You need to edit this file "/vendor/symfony/symfony/src/Symfony/Component/Validator/Constraints/File.php"

Replace this part:
$factors = array(
'k' => 1000,
'ki' => 1 << 10,
'm' => 1000000,
'mi' => 1 << 20,
);

with this
$factors = array(
'k' => 1000,
'ki' => 1 << 10,
'm' => 1000000,
'mi' => 1 << 20,
'g' => 1000000000,
'gi' => 1 << 30,
);

If you need more details, just let me know.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0