slimphp / Slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
http://slimframework.com
MIT License
11.94k stars 1.95k forks source link

PSR-7 compliance: Uploaded file structure is broken #1806

Closed aimeos closed 8 years ago

aimeos commented 8 years ago

We have some severe issues with multiple uploaded files. Can anyone confirm this?

HTML:

<input class="fileupload" name="image[files][]" multiple="" type="file">

$_FILES:

Array
(
    [image] => Array
        (
            [name] => Array
                (
                    [files] => Array
                        (
                            [0] => computer1.jpg
                        )
                )
            [type] => Array
                (
                    [files] => Array
                        (
                            [0] => image/jpeg
                        )
                )
            [tmp_name] => Array
                (
                    [files] => Array
                        (
                            [0] => /tmp/phpDyIKjr
                        )
                )
            [error] => Array
                (
                    [files] => Array
                        (
                            [0] => 0
                        )
                )
            [size] => Array
                (
                    [files] => Array
                        (
                            [0] => 4723
                        )
                )
        )
)

Result of Request::getUploadedFiles():

Array
(
    [image] => Array
        (
            [0] => Slim\Http\UploadedFile Object
        )
)

Expected from PSR-7:

Array
(
    [image] => Array
        (
        [files] => Array
            (
                [0] => Slim\Http\UploadedFile Object
            )
        )
)
geggleto commented 8 years ago

Our implementation is broken. https://github.com/slimphp/Slim/blob/3.x/Slim/Http/UploadedFile.php#L102-L137

Our implementation flatten's the _FILE structure.

We will need to have some form of recursion to maintain the index structure.

The fix will be a BC break.