我不知道我在哪裏做錯了沒有上傳的文件和名稱沒有存儲在數據庫中。圖片上傳不起作用laravel 5.4沒有得到任何錯誤
這裏是我的控制器
if(Input::hasFile('photo')) {
$fotoName = 'peg' . $employee->id . '.' .
$request->file('photo')->getClientOriginalExtension();
$request->file('photo')->move(
base_path() . '/public/images/employee/', $fotoName
);
$img = Image::make(base_path() . '/public/images/employee/' . $fotoName);
$img->resize(150, null, function ($constraint) {
$constraint->aspectRatio();
});
$img->save();
$employee_fotos = Karyawan::find($employee->id);
$employee_fotos->photo = $fotoName;
$employee_fotos->save();
}
查看
<form class="form-horizontal" role="form" action="{{ route("karyawan.store") }}" method="post" multiple>
{{ csrf_field() }}
<div class="row">
<!-- left column -->
<div class="col-md-3">
<div class="text-center">
<img src="//placehold.it/100" class="avatar img-circle" alt="avatar">
<h6>Upload a different photo...</h6>
<input type="file" name="photo" class="form-control" />
</div>
</div>
</form>
,我沒有得到任何錯誤,如果我做驗證其總是請添加圖像,或者確保文件擴展.JPG等,爲確定我有選擇正確的圖像和擴展