Image resize during upload?
I use classic function to upload images request()->file('userlogo')->store('userlogo/' , auth()->user()->id);
But how can I resize images in more sizes during upload? Or what is the best way to have image in more sizes? As storage I can use s3 and ftp...
Ok. I will take a look, is there required to save image name in a DB field or what is the best way get it after intervention?
No need to save files in db. Just save them in files with ur prefered file names. Like uploads/images/{user_id}/640X480.jpg
then how can I check if this image exist?
HI @lyonio You can try this :
if($request->hasFile('avatar')){
$avatar = $request->file('avatar');
$filename = time() . '.' . $avatar->getClientOriginalExtension();
Image::make($avatar)->resize(300, 300)->save( public_path('/uploads/avatars/' . $filename ) );
//$user = Auth::user();
$user->avatar = $filename;
$user->save();
};
I've used in this code Image facade
the filename is saved in the property avatar of the user in the database
$user->avatar = $filename;
note that the image is moved to the folder (public_path('/uploads/avatars/)with the name of the file and the extension.
Image intervention installation guide:http://image.intervention.io/getting_started/installation
I hope that helps
Please or to participate in this conversation.