/** * Home gallery image upload via ajax * * @param Request $request * */ public function admin_webgallery_upload(Request $request) { $img_data = Input::get("img_data"); $json = json_decode($img_data); $image_real = Input::file('img'); $img = Image::make($image_real->getRealPath()); $imgpath = "uploads/HomeGal/" . date('YmdHis') . '.' . $image_real->getClientOriginalExtension(); $width = ceil($json->width); $x = ceil($json->x); $y = ceil($json->y); $height = ceil($json->height); $img->crop($width, $height, $x, $y); $img->resize(2100, null, function ($constraint) { $constraint->aspectRatio(); }); $img->save($imgpath); $imgGal = new HOME_GALLERY(); $imgGal->path = $imgpath; $imgGal->caption = Input::get('caption'); $imgGal->caption_desc = Input::get('caption_desc'); $imgGal->save(); }