Level 6
It's getClientOriginalExtension().
This is using the original extension to save the new file - change line 3 to:
$filename = 'listing' . '-' . uniqid() . '.png';
1 like
I'm trying to change all images uploaded to png format. I'm using the Intervention Image package for Laravel, and calling the encode function. Image Files are not changing to .png
Here is my upload script: (Everything is uploading, resizing and appears to be compressing. Just not converting to a png file)
if($request->hasFile('listing_image')){
$classifiedImg = $request->file('listing_image');
$filename = 'listing'.'-'.uniqid().'.'.$classifiedImg->getClientOriginalExtension();
Image::make($classifiedImg)->encode('png', 65)->resize(760, null, function ($c) {
$c->aspectRatio();
$c->upsize();
})->save(public_path('/images/users/listing-images/' . $filename));
$classified->listing_image = $filename;
$classified->save();
}else{
$classified->save();
}
Am I doing something wrong in this section:
Image::make($classifiedImg)->encode('png', 65)->resize(760, null, function ($c)...
OR is this causing the issue:
getClientOriginalExtension();
It's getClientOriginalExtension().
This is using the original extension to save the new file - change line 3 to:
$filename = 'listing' . '-' . uniqid() . '.png';
Please or to participate in this conversation.