Help with a cycle

0

I have the following code that only saves the first image of the select, as I develop the cycle so that it saves all the selected images:

if(Input::file('img'))
    {
        $subir = $this->file->upload('categorias',Input::file('img'));
        $categoria->img = $subir->id;
    }

The form is simply the following:

<input type="file" name="img" id="file1" multiple="multiple">

    
asked by Sergio 21.06.2017 в 19:42
source

1 answer

0

I suppose you are using Laravel, it would be good if you detail that information in your question so that it will be useful to more people.

As for your question, you can implement it like this:

$categoria = [];
foreach(Input::file('img') as $imagen) {
    $subir = $this->file->upload('categorias',Input::file('img'));
    $categoria[]->img = $subir->id;
}
  

As shown in this help site: link

    
answered by 21.06.2017 в 19:56