When I trying upload image as profile, and then I get that message Trying to get property 'id' of non-object
public function update_image(Request $request)
{
$request->validate([
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2040',
]);
$user = Auth::user();
$imgName = $user->id.'_img'.time().'.'.request()->image->getClientOriginalExtension();
$request->image->storeAs('images', $imgName);
$request->image = $imgName;
$user->save();
return back()
->with('sucess', 'You have successful upload!');
}
How can I do it ?
And my route
Route::post('profile/img', 'Api\UserController@update_image');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire