Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Upload files in subarrays #56

Closed
oscarotero opened this issue Jun 18, 2015 · 2 comments
Closed

Upload files in subarrays #56

oscarotero opened this issue Jun 18, 2015 · 2 comments
Labels
Milestone

Comments

@oscarotero
Copy link
Contributor

Hi.
It seems that this library does not handle upload files in subarrays. For example, I have a form with this both fields:

<input type="file" name="images[big]" >
<input type="file" name="images[small]" >

On submit the form, I have a $_FILES like this:

Array
(
    [images] => Array
        (
            [name] => Array
                (
                    [big] => 14417316530_7c593bdff2_m.jpg
                    [small] => 14987901784_79fa14dacc_z.jpg
                )

            [type] => Array
                (
                    [big] => image/jpeg
                    [small] => image/jpeg
                )

            [tmp_name] => Array
                (
                    [big] => /private/var/tmp/phpuVQC7S
                    [small] => /private/var/tmp/phppe8WJs
                )

            [error] => Array
                (
                    [big] => 0
                    [small] => 0
                )

            [size] => Array
                (
                    [big] => 14377
                    [small] => 84186
                )
        )
)

On create a ServerRequest using ServerRequestFactory I have the following error:

<b>Fatal error</b>:  Uncaught exception 'InvalidArgumentException' with message 'Invalid leaf in uploaded files structure' in /Volumes/Documentos/www/psr7-test/vendor/zendframework/zend-diactoros/src/ServerRequest.php:293
Stack trace:
#0 /Volumes/Documentos/www/psr7-test/vendor/zendframework/zend-diactoros/src/ServerRequest.php(288): Zend\Diactoros\ServerRequest-&gt;validateUploadedFiles(Array)
#1 /Volumes/Documentos/www/psr7-test/vendor/zendframework/zend-diactoros/src/ServerRequest.php(288): Zend\Diactoros\ServerRequest-&gt;validateUploadedFiles(Array)
#2 /Volumes/Documentos/www/psr7-test/vendor/zendframework/zend-diactoros/src/ServerRequest.php(82): Zend\Diactoros\ServerRequest-&gt;validateUploadedFiles(Array)
#3 /Volumes/Documentos/www/psr7-test/vendor/zendframework/zend-diactoros/src/ServerRequestFactory.php(70): Zend\Diactoros\ServerRequest-&gt;__construct(Array, Array, Object(Zend\Diactoros\Uri), 'POST', 'php://input', Array)
#4 /Volumes/Documentos/www/psr7-test/proba.php(18): Zend\Diactoros\ServerRequestFactory::fromGlobals()
#5 {mai in <b>/Volumes/Documentos/www/psr7-test/vendor/zendframework/zend-diactoros/src/ServerRequest.php</b> on line <b>293</b><br />

I guess ServerRequestFactory should normalize the $_FILES array, somethink like symfony httpfoundation does

@samsonasik
Copy link
Contributor

handled by #57 ?

@jonhudson
Copy link

Yes, #57 should fix this.

@weierophinney weierophinney added this to the 1.0.4 milestone Jun 22, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants