【发布时间】:2018-01-28 06:07:01
【问题描述】:
我不知道我在哪里做错了文件没有上传并且名称没有存储在数据库中。
这是我的控制器
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 等,确保我选择了正确的图像和扩展名
【问题讨论】: