0

When creating a form with a multiple file field, symfony2 returns a UploadedFile object for the property of that field.

http://api.symfony.com/2.2/Symfony/Component/HttpFoundation/File/UploadedFile.html

A simple var_dump($data->getFiles()) (Method of the property $files) will return:

["files":"Acme\DemoBundle\Entity\FileUpload":private]=>
  object(Symfony\Component\HttpFoundation\File\UploadedFile)#12 (7) {
    ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> bool(false)
    ["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> string(10) "yop!!!.jpg"
    ["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> string(10) "image/jpeg"
    ["size":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> int(34088)
    ["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> int(0)
    ["pathName":"SplFileInfo":private]=> string(24) "C:\xampp\tmp\php42B5.tmp"
    ["fileName":"SplFileInfo":private]=> string(11) "php42B5.tmp"

This record stores just a single file data.

My question is: This object can handle multiple files ? or just single files ?

1 Answer 1

0

This object represents one file! But you can still have several files uploaded at once..each one gets a seperate FileUpload instance. Accept my pull request to give it a try.

Sign up to request clarification or add additional context in comments.

1 Comment

I was doubting if someone would answer the other question because it is bigger / more complex. Also thought that my question would be invalid If that object Or the form framework, doesn't allow to create multiple instances of it. Thank you again !! ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.