8000 [Form] Double file size validation when file is beyond the 'upload_max_filesize' parameter · Issue #32045 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[Form] Double file size validation when file is beyond the 'upload_max_filesize' parameter #32045
Closed
@COil

Description

@COil

Symfony version(s) affected: 4.3.1

Description
I have a double file size validation when file is beyond the 'upload_max_filesize' parameter.
In this case the max size is set to 500ko in the form and the max size allowed by php 2mo. Additionally the error message isn't translated.

sf-bug

How to reproduce

/**
 * Add or edit the avatar.
 */
class AvatarFormType extends AbstractType
{
    private const IMAGE_MAX_SIZE = 512000;  
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder->add('avatar', FileType::class, [
            'required' => true,
            'constraints' => [
                new NotBlank(),
                new Image([
                    'maxSize' => self::IMAGE_MAX_SIZE,
                ]),
            ],
        ]);
    }
}

and php setting :
upload_max_filesize | 2M | 2M

Possible Solution
Detect if a maxSize constraint already exists and is below the upload_max_filesize value?

See you. COil.

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