我不知道我在哪里做错了没有上传的文件和名称没有存储在数据库中。图片上传不起作用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等,为确定我有选择正确的图像和扩展