Laravel文件上传无法发布文件

时间:2018-01-24 22:55:56

标签: php html laravel-5

我正在尝试使用laravel上传文件 当我发布表单时,我的所有信息都已成功发布并显示为

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

当我尝试$ request-all();

时,我的文件没有出现在列表中

以下是我的相关HTML代码

<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>

我是棱角分明的新手,所以如果我遗失任何东西,请告诉我

2 个答案:

答案 0 :(得分:2)

文件上传未显示在$request->all()

您需要直接引用它们,即$request->file('file')。您可以通过$request->files获取集合中的所有文件。

答案 1 :(得分:1)

尝试将enctype="multipart/form-data"添加到表单

相关问题