Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files initialization does not normalize the _FILES array completely #57

Open
proggeler opened this issue Feb 5, 2021 · 1 comment
Open
Labels

Comments

@proggeler
Copy link
Contributor

proggeler commented Feb 5, 2021

When one or more files are sent using a file input with a "simple" name, the Files class contains a normalized array, where each leave is a (so called) target array.

// <input type="file" name="photo[]" multiple>
[
    'photo' => [
        0 => [
            'error' => 0,
            'name' => 'photo-1.jpg',
            'size' => 190912,
            'tmp_name' => '/tmp/phphjLCGX',
            'type' => 'image/jpeg',
        ],
        1 => [ /* the next photo entry */ ],
    ]
]

When the name of the file input references an array key, I would expect all leaves are a target to.
That is not true, it stores the data as follows:

// <input type="file" name="user[photo][]" multiple>
[
    'user' => [
        'photo' => [
            'error' => [
                0 => 0,
                1 => 0,
            ],
            'name' => [
                0 => 'photo-1.jpg',
                1 => 'photo-2.png',
            ],
            'size' => [
                0 => 190912,
                1 => 190912,
            ],
            'tmp_name' => [
                0 => '/tmp/phphjLCGX',
                1 => '/tmp/phpH7JvcD',
            ],
            'type' => [
                0 => 'image/jpeg',
                1 => 'image/png',
            ],
        ],
    ],
]

I would expect this to be:

[
    'user' => [
        'photo' => [
            0 => [
                'error' => 0,
                'name' => 'photo-1.jpg',
                'size' => 190912,
                'tmp_name' => '/tmp/phphjLCGX',
                'type' => 'image/jpeg',
            ],
            1 => [
                'error' => 0,
                'name' => 'photo-2.png',
                'size' => 190912,
                'tmp_name' => '/tmp/phpH7JvcD',
                'type' => 'image/png',
            ],
        ],
    ]
]

If this get fixed, this will be a breaking change for current implementations.
(if you need assistance fixing this, maybe you can setup a 3.x branch for me as a starting point for development)

@proggeler proggeler changed the title Files initialization does not normalizes the _FILES array completely Files initialization does not normalize the _FILES array completely Feb 18, 2021
@harikt
Copy link
Member

harikt commented Jun 21, 2022

As I am not using Aura for the current time, I don't have enough time to maintain a newer version of Aura.Web ( 3.x ... ) .

Instead I would recommend people to go for the newer ones by @pmjones : https://github.com/sapienphp .

Here, I just want to make sure the packages can be installed in newer versions of PHP .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants