[英]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();
返回所有表單輸入。 所以試試這個Input::file('logo');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.