Level 60
Apr 10, 2022
6
Level 4
how to Resize image during upload
I am trying to resize image before i upload it i want the width: 736px and height:530px
i have this in my controller
public function store(PostRequest $request)
{
if($request->featured_image)
{
$exploded = explode(',', $request->featured_image);
$decoded = base64_decode($exploded[1]);
$fileName = Str::slug("{$request->title}.jpg");
$request->merge(['featured_image' => $fileName]);
Storage::disk('public')->put($fileName, $decoded);
}
$post = Post::create([
'title' => $request->title,
'body' => $request->body,
'excerpt' => $request->excerpt,
'user_id' => auth()->id(),
'featured_image' => $request->featured_image,
]);
$post->categories()->attach($request->catSelected);
return response()->json([
'post' => $post,
'message' => 'Post created successfully.'
], 200);
}
Not sure how to handle the resizing
Any help would be appreciated.
Please or to participate in this conversation.