bootstrap file input with laravel - no upload file

3.1k views Asked by At

i use laravel 53 and try to use http://plugins.krajee.com/ as file input. The problem is: no file upload will be done. This is the relevant part of my blade code:

<form class="form-horizontal" role="form" id="myuseredit" method="POST" action="{{ url('upload') }}" >
...
<div class="col-md-10 ">
    <input id="filedata" name="filedata[]" type="file" multiple class="file-loading">
    <script>
    $("#filedata").fileinput({
        uploadAsync: true,
        maxFileCount: 5
    });
    </script>                       
</div>
</form>
...

And this is the corrosponding controller code:

public function upload(Request $request) {
  dd($request->all());
...

The request shows me only the Name of the original file, what i picked to upload. But nothing more, no upload, no files (on server).

bfo

1

There are 1 answers

2
Jerodev On

If you want to upload files, you have to add enctype="multipart/form-data" to your form tag so the browser knows you want to upload files.

Like so:

<form class="form-horizontal" role="form" id="myuseredit" method="POST" action="{{ url('upload') }}" enctype="multipart/form-data">