We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Uploading multiple images

Hello people, First of all sorry for my bad english, it is not my first language.

I am trying to upload multiple images with this code it works:

<form method="post" autocomplete="off" enctype="multipart/form-data" action="images/upload"> <input type="file" name="files[]" multiple> <input type="submit" value="Upload Image(s)"> </form>

but i want to create a phalcon form like this (Imageuploadform.php):

public function initialize()
{
    $image = new File('image',array(
    ));
    $this->add($image);
     $this->add(new Submit('upload', array(
        'class' => 'btn btn-success'
    )));
}

index.volt:

<form method="post" autocomplete="off" enctype="multipart/form-data" action="image/upload"> {{ form.render('image') }} {{ form.render('upload') }} </form>

but that only works for 1 image.

I tried to search it but didnt find any solutions. PS: I know how to work with the controller and check every file so thats why i didnt post my controller code. Thanks for the help!



994
Accepted
answer

I fixed it for all people who want to know.

$image = new File('image',array( multiple => 'true' )); $this->add($image);

that will fix it