I have a small problem concerning the resizing process of a given image, I am trying to submit a form containing an input type -->file<-- I was able to upload a picture witho
Uploading a file and resizing it before saving is as easy as that: (Without validation or checks)
You can directly pass an instance of UploadedFile to InterventionImage::make()
public function upload(Request $request)
{
$file = $request->file('file');
$filename = $file->getClientOriginalName();
$img = \Image::make($file);
$img->resize(320, 240)->save(public_path('uploads/'.$filename))
}
If you want to save original size and resized image:
$img->save(public_path('uploads/'.$filename))
->resize(320, 240)
->save(public_path('uploads/thumb_'.$filename));
This was just tested on currently latest 5.2 version with is 5.2.45
[EDIT:]
If you call
$file->move();
Don't use
$file->getRealPath()
afterwards, because this will return false after calling move()
$filename = $file->getClientOriginalName();
$file->move('uploads', $filename);
dd($file->getRealPath());