Skip to content

Instantly share code, notes, and snippets.

@vimalmistry
Created June 26, 2017 09:39
Show Gist options
  • Save vimalmistry/7f976399124a65c856f17ce8ec407924 to your computer and use it in GitHub Desktop.
Save vimalmistry/7f976399124a65c856f17ce8ec407924 to your computer and use it in GitHub Desktop.
<?php
public function fileUploadAndResize(Request $request, $user)
{
ini_set('memory_limit', '256M');
if ($request->file('image')) {
$image = $request->file('image');
$filename = uniqid($user->id) . '.' . $image->getClientOriginalExtension();
$path = public_path('images') . '/' . $filename;
\Image::make($image->getRealPath())
->resize(200, 200)
->save($path);
return $filename;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment