【发布时间】:2017-04-03 15:53:01
【问题描述】:
我正在尝试使用 bootstrap-fileinput 插件在 laravel 项目中上传个人资料图片 这是风景
@section('content')
<div class="fileinput fileinput-new" data-provides="fileinput">
<div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
<img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&text=no+image" alt="" /> </div>
<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"> </div>
<div>
<span class="btn default btn-file">
<span class="fileinput-new"> Select image </span>
<span class="fileinput-exists"> Change </span>
<input type="file" name="..."> </span>
<a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput"> Remove </a>
</div>
</div>
@endsection
目标是将此图像上传到存储目录并将文件路径存储在 db 表中,但我不知道如何执行此操作,我通过 POST 将表单提交到控制器中的存储方法。 这是那个函数
public function store(Request $request)
{
//
$this->validate($request, [
'first_name' => 'required',
'dob' => 'required',
'mobile_no' => 'unique:customers',
'adhar_no' => 'unique:customers',
]);
$customer = new customer;
$customer->first_name = $request->first_name;
$customer->last_name = $request->last_name;
$customer->gender = $request->gender;
$customer->dob = $request->dob;
$customer->mobile_no = $request->mobile_no;
$customer->adhar_no = $request->adhar_no;
$customer->street = $request->street;
$customer->save();
return redirect('home/customer');
}
请帮忙
【问题讨论】:
标签: twitter-bootstrap file-io laravel-5 laravel-5.4