Laravel 表单模型与文件上传的绑定不起作用

Laravel Form Model Binding with File Upload is not working

我正在尝试在 laravel 5.2 中上传带有表单模型绑定的文件。但它不起作用我没有在控制器中获取文件数据。

{!! Form::model($settings, ['route' => ['admin.settings.update', $settings->id], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH',  'fiels' => true  , 'id' => 'edit-settings']) !!}

<div class="form-group">

    {!!  Form::file('logo') !!}

</div>

{!! Form::close() !!}

在 Controller 中,我已经正确导入了 Input Facades 并尝试像这样获取文件对象。

$image = Input::all('logo'); 
OR
$image = Input::file('logo');

但我得到的是文件名,而不是整个文件对象。

像这样更新你的表单模型,你拼错了文件名

{!!Form::model($settings, ['route' => ['admin.settings.update', $settings->id], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH',  'files' => true  , 'id' => 'edit-settings']) !!}

然后在您的控制器中执行此操作,

Input::file('logo'); 而不是 Input::all('logo'); 因为 Input::all(); return 都是表单输入。所以试试这个 Input::file('logo');