If i comment this line of code $this->resizeProfilePhoto($file)
i haven't any token error, but what is wrong with this?
public function updateProfilePhoto(Request $request)
{
$this->validate($request, [
'profilePhoto' => 'required:mimes:jpg,png,bmp'
]);
$user = User::find(Auth::user()->id);
$file = $request->file('profilePhoto');
//$this->resizeProfilePhoto($file);
$newName = md5(time() . $file->getClientOriginalName()) . str_random(15) .'.jpg';
$user->photo_path = $newName;
$file->move(
(User::PHOTO_PATH),
User::userPhoto($user, 'orginal')
);
$user->save();
return 'Done';
}
public function resizeProfilePhoto($file)
{
try
{
$img = Image::make(
$file->getRealPath()
);
$img->fit(200);
return $img->save(public_path('images') .'/'. 'test.jpg');
}
catch(Exeption $e)
{
return false;
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire