I am trying to use bootstrap-fileinput plugin to upload a profile image in a laravel project here is the view
@section('content')
<div class="fileinput fileinput-new" data-provides="fileinput">
<div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
<img src="http://ift.tt/1p382He" 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
The objective is to upload this image to storage dir and store the path to file in db table, but I have no clue how to do that, I am submitting the form via POST to a store method in my controller. Here is that function
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');
}
Please help
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire