**how create image thumbnails use different library thumbnail not create **
public function store(request $request){ $user_id = \auth::user()->id; $image = new image(); $this->validate($request, [ 'title' => 'required', 'description' => 'required', 'image' => 'required' ]); $image->title = $request->title; $image->description = $request->description; $image->user_id = $user_id; if($request->hasfile('image')) { $file = input::file('image'); //getting timestamp $timestamp = str_replace([' ', ':'], '-', carbon::now()->todatetimestring()); $name = $timestamp. '-' .$file->getclientoriginalname(); $image->filepath = $name; $file->move(public_path().'/images/', $name); } $image->save(); return $this->upload()->with('success', 'image uploaded successfully'); }
** **how create image thumbnails use different library thumbnail not create ****
i'll suggest use intervention/image
package, pairs nicely laravel
.
after install it, here example of uploading , saving image , creating thumbnail out of it.
$image = image::make(input::file('photo')->getrealpath()); $image->save(public_path('photos/'. $id .'.jpg')); $image->fit(300, 200)->save(public_path('photos/'. $id .'-thumbs.jpg'));
Comments
Post a Comment