mardi 3 juillet 2018

Laravel 5.6 check and store multidimensional file array issue

I can't get how to manage files in the controller if my file input is a multidimensional array. I'am stuck with this.

I.e. my html form:

<form>
   ... lots of stuff before images ...
   <input type="file" name="myImage[0][0]" />
   <input type="file" name="myImage[0][1]" />
   <input type="file" name="myImage[1][0]" />
   ...
   <input type="file" name="myImage[5][3]" />
</form>

What the correct way would be for request variable in my controller to store those files?

In my case I already have preprocessed ids for request array, but seems it doesnt work with file type:

$form_item->title = $request->input('title')[$parent][$child]; // works fine

$form_item->image = $request->file('myImage')[$parent][$child]->store('images'); // Call to a member function store() on null

$form_item->save();

How to store file and apply hasFile validation in my case?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire