I am trying to load the user current image(Image URL saved in db)in Edit Form... If new image in edit form is not selected i get this error...
Undefined variable: image_path
Here is my update function
public function update(Request $request,User $user)
{
$get_user = Auth::user();
if(Input::hasFile('image'))
{
$user_email = $get_user->email;
$image = request()->file('image');
$image_extension = $image->guessClientExtension();
$image_path = $image->storePubliclyAs('public/uploads/profile_images/images', $user_email . ".{$image_extension}");
}
$user->firstname = $request->get('firstname');
$user->lastname = $request->get('lastname');
$user->company= $request->get('company');
$user->address= $request->get('address');
$user->phone = $request->get('phone');
$user->country= $request->get('country');
$user->zipcode = $request->get('zipcode');
$user->city = $request->get('city');
$user->state = $request->get('state');
$user->skills = $request->get('skills');
$user->interests = $request->get('interests');
$user->about = $request->get('about');
$user->website = $request->get('website');
$user->image_url = $image_path;
$user->save();
$request->session()->flash('message.level', 'success');
$request->session()->flash('message.content', 'Profile Updated Successfully !');
return redirect()->route('dashboard');
}
Please Help and give me a solution to handle a scenerio if user not selected the image in Edit form..
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire