Enrique Martinez
Enrique Martinez

Reputation: 128

Laravel file Upload fails to post file

I am trying to upload a file using laravel
When I post the form all of my information is successfully posted and appears like so

Array ( [_token] => 6pFFn8JzbtB5XJBYaAIFW4Z1pTKZCA0aZCGKgfCu 
       [firstName] => En 
       [middleName] => we 
       [lastName] => Ma 
       [date] => 2018-01-02 
       [highSchool] => asd 
       [studentId] => 123  
       [address] => 123 aj  
       [email] =>[email protected] )  

My file does not appear on the list when I try $request-all();

Below is my relevant HTML code

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

<div class="form-group{{ $errors->has('file') ? ' has-error' : '' }}">
                        <label for="file" class="col-md-4 control-label"> Resume:</label>
                        <div class="col-md-6">
                          <input name="file" type="file" id="file" required>
                            @if ($errors->has('resume'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('resume') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>

I'm new to angular so please let me know if I am missing anything

Upvotes: 1

Views: 96

Answers (2)

ceejayoz
ceejayoz

Reputation: 179994

File uploads do not appear in $request->all().

You need to refer to them directly, i.e. $request->file('file'). You can get all the files in a collection via $request->files.

Upvotes: 2

Kuba Zabielski
Kuba Zabielski

Reputation: 156

Try to add enctype="multipart/form-data" to your form

Upvotes: 1

Related Questions