Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Form] Double file size validation when file is beyond the 'upload_max_filesize' parameter #32045

Copy link
Copy link
Closed
@COil

Description

@COil
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.