Level 20
Try by changing the name
...
<input type="file" id="file" name="file[]" multiple/>
...
2 likes
Hey,
I'm trying to make an upload section in my application. But how can I make sure that people can upload multiple files?
Right now I've this: HTML:
<form class="form-horizontal" method="post" action="/createticket" enctype="multipart/form-data">
{!! csrf_field() !!}
<div class="form-group">
<label for="File upload" class="col-lg-2 control-label" >File upload</label>
<div class="col-lg-10">
<input type="file" id="file" name="file" multiple/>
</div>
</div>
</form
And my controller:
public function storeTicket(makeTicketRequest $request)
{
//save documents
$file = $request->file('file'));
$name = time() .$file->getClientOriginalName();
$userid = Auth::user()->id;
$file->move('files/'.$userid,$name);
$ticket->image()->create(['path' => '/files/'.$userid.'/'.$name]);
}
Off course I should $file in a foreach but when I dd($file) it's only showing one file but I did upload 2 files:
UploadedFile {#29 ▼
-test: false
-originalName: "Schermafbeelding 1394-10-13 om 11.53.15.png"
-mimeType: "image/png"
-size: 169485
-error: 0
}
Please or to participate in this conversation.