Skip to content

Instantly share code, notes, and snippets.

@sineld
Created September 25, 2012 08:11
Show Gist options
  • Save sineld/3780572 to your computer and use it in GitHub Desktop.
Save sineld/3780572 to your computer and use it in GitHub Desktop.
Laravel File Upload And Resize
<?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);
}
?>
@kenjox
Copy link

kenjox commented Aug 8, 2013

Nice tut.Do you have a snippet on how to upload files using laravel 4 and enable users to download the uploaded files?

@dannymichel
Copy link

Laravel no longer supports Bundle::start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment