Skip to content

Instantly share code, notes, and snippets.

@grajib23
Forked from sineld/laravel-upload-resize.php
Created August 1, 2013 06:07
Show Gist options
  • Select an option

  • Save grajib23/6128770 to your computer and use it in GitHub Desktop.

Select an option

Save grajib23/6128770 to your computer and use it in GitHub Desktop.

Revisions

  1. @sineld sineld revised this gist Sep 25, 2012. 1 changed file with 0 additions and 4 deletions.
    4 changes: 0 additions & 4 deletions laravel-upload-resize.php
    Original file line number Diff line number Diff line change
    @@ -30,8 +30,4 @@ public function post_edit_logo($id)
    // move uploaded file to public/uploads
    Input::upload('logo', 'public/uploads', $filename);
    }
    So I first resized the image and then uploaded it.
    And the second part was that the save method accepts an file path rather than a directory path. Didn't look close enough at the documentation...
    Thanks everybody for your help.

    ?>
  2. @sineld sineld created this gist Sep 25, 2012.
    37 changes: 37 additions & 0 deletions laravel-upload-resize.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    <?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);
    }
    So I first resized the image and then uploaded it.
    And the second part was that the save method accepts an file path rather than a directory path. Didn't look close enough at the documentation...
    Thanks everybody for your help.

    ?>