Can you explain me these two lines to me?
$userDetails = Auth::user();
$user = User::find($userDetails->id);
Actually its working when i am not using enctype="multipart/form-data" but when i add it database is not adding my filename to it here is the form code
@csrf Full Name </div>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" value="{{ $data->email }}" name="email" class="form-control" id="user_email" placeholder="Enter Your Email">
</div>
<div class="form-group">
<label for="exampleInputFile">Profile Image</label>
<div class="input-group">
<div class="custom-file">
<input type="file" name="profile_pic" class="custom-file-input" id="profile-image">
<label class="custom-file-label" for="exampleInputFile">Recommended Profile Image (160w x 160h)</label>
</div>
</div>
<span class="font-italic text-warning">Picture size should be less than 4MB</span>
</div>
</div>
<div class="card-footer">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
and here is the controller code
public function update(Request $request)
{
$userDetails = Auth::user();
$user = User::find($userDetails ->id);
$user->full_name=$request->input('full_name');
$user->email=$request->input('email');
$user->profile_pic=$request->input('profile_pic');
// if($request->hasFile('profile_pic'))
// {
// $avatar = $request->file('profile_pic');
// $filename = time().'.'.$avatar->getClientOriginalExtension();
// $location = storage_path('app/public/uploads/'.$filename);
// Image::make($avatar)->resize(300, 300)->save($location);
// $user = Auth::user();
// $user->profile_pic = $filename;
// }
$user->save();
return redirect()->back()->with('success','Sucessfully changed User Information');
}
And please also tell me how can i upload it to my storage because its not working !
Please or to participate in this conversation.