title: Uploading profile image in laravel framework
body: <p>Hi I am newbie to laravel framework, I am developing a dashboard, When the user update his details along with profile photo in dashboard i am not getting any error,But when the user update only the details keeping the image as same(not updating image),  I am getting an error:  "Call to a member function getClientOriginalName() on a non-object"</p>
  
  <p>My blade.php is:</p>
  
  <pre><code>{{ Form::open(array('route' =&gt; 'account.profile-update', 'class' =&gt; 'form-horizontal', 'files'=&gt;true)) }}
  
  &lt;div class="uploader" id="uniform-file"&gt;
                      {{Form::file('fileinput')}}
                      &lt;span class="filename" style="-webkit-user-select: none;"&gt;Upload Image&lt;/span&gt;
                      &lt;span class="action" style="-webkit-user-select: none;"&gt;Browse&lt;/span&gt;
                  &lt;/div&gt;
                  &lt;div&gt;Please upload image of size 150x150 pixels&lt;/div&gt;
              &lt;/div&gt;
  </code></pre>
  
  <p>my  UserController.php:</p>
  
  <pre><code>public function updateProfile()
  {
       $input = Input::all();        
        if ($this-&gt;user-&gt;updateUser($input)) {
            return Redirect::back()-&gt;withMessage('Data saved successfully');
        } else {
           return View::make('error.generic-errors')-&gt;withErrors($this-&gt;user-&gt;getMessages());
        }
   }
  </code></pre>
  
  <p>my UserRepository.php:</p>
  
  <pre><code>   public function updateUser(array $attributes)
  {
      $user = $this-&gt;getLoggedUser();
      if (strcmp($user-&gt;first_name, $attributes ['first_name']) !== 0)
          $user-&gt;first_name = $attributes ['first_name'];
      if (strcmp($user-&gt;last_name, $attributes ['last_name']) !== 0)
          $user-&gt;last_name = $attributes ['last_name'];
      if (strcmp($user-&gt;email, $attributes ['email']) !== 0)
          $user-&gt;email = $attributes ['email'];
      $this-&gt;updateUserInfo($attributes);
      if ($user-&gt;save()) {
          return true;
      } else {
          $this-&gt;messageBag-&gt;add('update_profile', 'Error while saving user details in profile page');
          return false;
      }
  }
  
   private function updateUserInfo($attributes)
  {
      $user_detail = UserDetail::where('user_id', '=', $this-&gt;getLoggedUserID())-&gt;firstOrFail();
      if (array_key_exists('fileinput', $attributes)) {
          if (!is_null($user_detail-&gt;picture)) {
              File::delete(public_path() . $user_detail-&gt;picture);
          }
          $user_detail-&gt;picture = $this-&gt;getImageName($attributes);
      }
      $user_detail-&gt;updateIfKeyExists($attributes);
  }
  
     private function getImageName(array $attributes)
  {
      if (!array_key_exists('fileinput', $attributes)) {
          return null;
      }
      $file = Input::file('fileinput');
      $destinationPath = public_path().Config::get('far.profile_pic_folder');                                    
      $temp_filename = 't_' . str_random(6) . '_' . substr($file-&gt;getClientOriginalName(), -40);
      $new_filename = substr($temp_filename, 2);
      $uploadSuccess = $file-&gt;move($destinationPath, $temp_filename);
      //TODO - check and handle for large filesize
      $img = Image::make($destinationPath . $temp_filename)-&gt;resize(150, 143)-&gt;save($destinationPath . $new_filename);
      File::delete($destinationPath . $temp_filename);
      return Config::get('far.profile_pic_folder') . $new_filename;
  }
  </code></pre>
  
  <p>Please Help me to solve this.
  Thanks in advance</p>