I want to upload photos in server. But before that I want to rotate that image. My code is like below,
$photo = $request->file($field);
$temp = imagecreatefromjpeg($photo);
$rotated = imagerotate($temp, 270, 0);
$extension = $photo->getClientOriginalExtension();
$flieNametoStore = time()."___".explode('.',$photo->getClientOriginalName())[0].'.'.$extension;
Storage::disk('public')->put($flieNametoStore, $rotated);
It is not working. It shows error like supplied resource is not a valid stream resource
.
I also tried Storage::disk('public')->put($flieNametoStore, File::get($rotated));
but still it doesn't work.
So, I have two questions. What can I do to achieve my objective? (rotate and save in server.) Also, I have used imagecreatefromjpeg function. However, I want to execute same code for other file type.(All types supported by laravel validation of image.)
I searched in SO and found some similar questions. However, those solutions are not giving me my desired output.