I have a form in which user should at least select one file to be uploaded. I have three file input fields like this:
<div class="form-group col-lg-4">
{!! Form::label('file1', 'Select file 1', ['class' => 'control-label']) !!}
{!! Form::file('files[]', ['id'=>'file1']) !!}
</div>
<div class="form-group col-lg-4">
{!! Form::label('file2', 'Select file 2', ['class' => 'control-label']) !!}
{!! Form::file('files[]', ['id'=>'file2']) !!}
</div>
<div class="form-group col-lg-4">
{!! Form::label('file3', 'Select file 3', ['class' => 'control-label']) !!}
{!! Form::file('files[]', ['id'=>'file3']) !!}
</div>
I should validate the presence of at least one file and the mime types in a form request. Then in the store method of the related form controller, the original file names should be stored in the three corresponding database fields(namely file1, file2, file3).
How can I implement this?
After some searching around I finally came up with a solution. First of all I modified the view to look like this:
Then in the controller I used your suggested code: