Reputation: 31
I have input tag in my form that get multiple image, but when I post form to my controller only last image passed.
this is my form
<form class="floating-labels m-t-40" method="post" action="{{asset(route('products.store'))}}" enctype="multipart/form-data" >
<input type="hidden" name="_token" value="{{csrf_token() }} ">
<input type="file" name="other_file[]" id="images" multiple="multiple"/>
</form>
when I dd($request)
in my controller
only show last image details.
Is there any hope?
Upvotes: 2
Views: 279
Reputation: 527
For me It works like this:
if($request->hasFile('attachment'))
{
$files = $request->file('attachment');
foreach ($files as $file) {
.....
}
}
The html part
<input type="file" name="attachment[]" multiple>
Upvotes: 1