Skip to content

Instantly share code, notes, and snippets.

@jayeshcp
Forked from sineld/laravel-upload-resize.php
Last active August 29, 2015 13:56
Show Gist options
  • Save jayeshcp/9003020 to your computer and use it in GitHub Desktop.
Save jayeshcp/9003020 to your computer and use it in GitHub Desktop.
Resize uploaded image in Laravel
<?php
// Resizer and Image Manipulation
// Based on: http://forums.laravel.com/viewtopic.php?id=2648
public function post_edit_logo($id)
{
$rules = array(
'image' => 'image',
);
$validation = Validator::make(Input::file('logo'), $rules);
// create random filename
$filename = Str::random(20) .'.'. File::extension(Input::file('logo.name'));
// Save logo in the database
$event = Events::where('user_id', '=', $id)->first();
$event->logo = $filename;
$event->save();
// start bundle 'resizer'
Bundle::start('resizer');
// resize image
$img = Input::file('logo');
$success = Resizer::open($img)
->resize(60 , 30 , 'auto' )
->save('public/uploads/thumbnails/'.$filename , 90 );
// move uploaded file to public/uploads
Input::upload('logo', 'public/uploads', $filename);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment