I have the following code in my view:
Code: Select all
<div id="admin">
<h1>Products Admin Panel</h1><hr>
<p>Here you can view, delete, and create new products.</p>
<h2>Products</h2><hr>
{{ Form::open(array('url'=>'admin/fileupload/create' , 'files'=>true)) }}
<p>
{{ Form::file('image') }}
</p>
{{ Form::submit('Create Product' , array('class'=>'secondary-cart-btn')) }}
{{ Form::close() }}
</div> <!-- end admin -->
Code: Select all
public function postCreate() {
$fileupload = new Fileupload;
$height = 200;
$width = 400;
$mode = ImageInterface::THUMBNAIL_OUTBOUND;
$size = new Box($width, $height);
$image = Input::file('image');
$filename = date('Y-m-d-H-i-s')."-".$image->getClientOriginalName();
$path = public_path('img/testsave/' .$filename);
$thumbnail = Imagine::open($path ."jpg")->thumbnail($size, $mode);
$fileupload->save();
return Redirect::to('admin/products/index')
->with('message' , 'Product created');
}
Code: Select all
$mode = ImageInterface::THUMBNAIL_OUTBOUND;
Code: Select all
Imagine::open
http://i.imgur.com/35QXajK.jpg ,
Is the code in my controller correct ? what am i doing wrong ?
My objective is to grab the image once the user presses submit , change the name and use imagine to resize the image. and save it.