We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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!



1.0k
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