简体   繁体   中英

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] =>mail@hotmail.com )  

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

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

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

尝试在enctype="multipart/form-data"添加enctype="multipart/form-data"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM