public function plupload($filePath)
 {
     $plupload = new Plupload();
     $fileName = date("_YmdHis") . rand(1000, 9999) . '.';
     $plupload->process('file', function ($file) use(&$fileName, &$filePath) {
         $fileName = $fileName . $file->getClientOriginalExtension();
         $file->move(public_path($filePath), $fileName);
     });
     $fullPath = public_path($filePath) . $fileName;
     if (file_exists($fullPath)) {
         $img = Image::make($fullPath);
         $imgMime = explode('/', $img->mime());
         $fileMime = $imgMime[0];
         if ($fileMime == 'image') {
             $img->resize(300, null, function ($constraint) {
                 $constraint->aspectRatio();
                 $constraint->upsize();
             });
             $img->save(public_path($filePath) . 'thumb' . $fileName);
             $thumbUrl = $filePath . 'thumb' . $fileName;
             $info['result'] = true;
             $info['file'] = $filePath . $fileName;
             $info['thumb'] = $thumbUrl;
             $info['type'] = $fileMime;
             return $info;
         }
     } else {
         $info['result'] = false;
         return $info;
     }
 }
 public function postSaveCover()
 {
     $filePath = '/uploads/pages/covers/' . date("Ymd") . '/';
     if (Request::hasFile('file')) {
         $plupload = new Plupload();
         $fileName = date("_YmdHis") . rand(1000, 9999) . '.';
         $response = $plupload->process('file', function ($file) use(&$fileName, &$filePath) {
             $fileName = $fileName . $file->getClientOriginalExtension();
             $file->move(public_path($filePath), $fileName);
         });
     }
     if (file_exists(public_path($filePath) . $fileName)) {
         $img = Image::make(public_path($filePath) . $fileName);
         $imgMime = explode('/', $img->mime());
         if ($imgMime[0] != 'image') {
             $response['result'] = false;
             return Response::json($response);
         }
     } else {
         $response['result'] = false;
         return Response::json($response);
     }
     $img->resize(300, null, function ($constraint) {
         $constraint->aspectRatio();
         $constraint->upsize();
     });
     $img->save(public_path($filePath) . 'thumb' . $fileName);
     $response['result'] = true;
     $response['cover'] = $filePath . $fileName;
     $response['thumb'] = $filePath . 'thumb' . $fileName;
     return Response::json($response);
 }