I code an Profile Page where i can edit all Fields like:
Profile Text
Profile Description
image1 upload
image2 upload
With my Code i can Edit and Update only the other fields if i have Uploaded the myimagename1 Picture and dont have an Upload code for the second one:
public function EditProfile(Request $request){
if($request->hasFile('myimagename1')){
if ($request->file('myimagename1')->isValid()) {
$user = Auth::user();
$user->profile = $request->pd;
$user->description= $request->description;
$user->profileimage = date('mdYHis') . uniqid() . $request->profileimage;
$image_name = date('mdYHis') . uniqid() . $request->file('myimagename1')->getClientOriginalName();
$path = base_path() . '/public/img';
$request->file('myimagename1')->move($path,$image_name);
$user->myimagename1 = "/img/$image_name";
$user->save();
return redirect()->back();
}
return redirect()->back()->with('error', 'image not valid');
}
return redirect()->back()->with('error', 'no image');
}
How can i change this Code that i can edit and update all separate and an Image If for every image and can also upload in storage the second image too?
Thats my Default code:
public function EditProfile(Request $request){
$user = Auth::user();
$user->profile = $request->pd;
$user->description= $request->description;
$user->profileimage = date('mdYHis') . uniqid() . $request->profileimage;
$user->myimagename1= date('mdYHis') . uniqid() . $request->myimagename1;
$user->save();
return redirect()->back();
}
Thanks anyone!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire