Example #1
0
 public function postAvatar()
 {
     return \Plupload::receive('file', function ($file) {
         // Store the uploaded file
         $email = \Auth::user()->email;
         $path = storage_path() . '/profiles/' . $email . '/avatar/';
         if (!file_exists($path)) {
             \File::makeDirectory($path, $mode = 0777, $recursive = true);
             $path = storage_path() . '/profiles/' . $email . '/avatar/avatar.jpg';
             \Image::make($file->getRealPath())->save($path, 30);
         }
         $path = storage_path() . '/profiles/' . $email . '/avatar/avatar.jpg';
         if (file_exists($path)) {
             chown($path, 465);
             unlink($path);
         }
         \Image::make($file->getRealPath())->fit(1000, 1000)->save($path, 30);
     });
 }
 public function postUseravatar()
 {
     return \Plupload::receive('file', function ($file) {
         // Store the uploaded file
         $email = \Request::input('email');
         $path = storage_path() . '/profiles/' . $email . '/avatar/';
         \File::makeDirectory($path, $mode = 0777, $recursive = true);
         $path = storage_path() . '/profiles/' . $email . '/avatar/avatar.jpg';
         \Image::make($file->getRealPath())->save($path, 30);
     });
 }