Skip to content
Advertisement

Laravel collective form, how to upload multiple images?

I wan’t to change my form to enable more than one image to be uploaded at a time, this is what I currently have,

part of my form:

JavaScript

my controller:

JavaScript

thanks for your help!

Advertisement

Answer

For the file helper you should use unescaped rendering:

{!! Form::file('stock_image') !!}

If you want to upload multiple files you just have to use multiple input fields.

JavaScript

If you want them in an array you can use the following syntax:

JavaScript

If you want to process the last one you can do the following:

An other tip: You can use the 'files' => true option for the Form::open() method instead of manually setting the enctype. It’s a helper option.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement