Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Form] Files upload is broken for PHP 8.1 because of new key full_path is added #46146

Closed
@p-golovin

Description

@p-golovin

Symfony version(s) affected

5.4.7, 6.0.7, 6.1

Description

There is hardcoded array of keys for $_FILES in https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Form/NativeRequestHandler.php.

It is checked against posted data in two cases:
https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Form/NativeRequestHandler.php#L204
https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Form/NativeRequestHandler.php#L240

In PHP 8.1 was added new key full_path (https://php.watch/versions/8.1/$_FILES-full-path). As a result check is broken and we get incorrect format of image's array at https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Form/NativeRequestHandler.php#L93 and error that form contains not allowed extra fields.

image

How to reproduce

We use Form component as standalone without entire framework but within our cms. Problem looks obvious, but if it will be needed, I'll try to create code for reproduce problem.

Possible Solution

I've found that such problem was already fixed in HttpFoundation component: #42112

Additional Context

No response

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