title: Uploading an image in Codeigniter shows error The upload path does not appear to be valid
body: <pre><code>$config['upload_path'] = site_path().'photos/';
  $config['allowed_types'] = 'gif|jpg|png|jpeg';
  $config['max_size'] = '2048';
  $this-&gt;load-&gt;library('upload', $config);    
  if ( ! $this-&gt;upload-&gt;do_upload())
  { 
      $this-&gt;data['alert'] = $this-&gt;upload-&gt;display_errors();                     
      $this-&gt;load-&gt;view('profile/photo', $this-&gt;data);
  }   
  else
  {
      $upload_data = $this-&gt;upload-&gt;data();
  
      $filename = $upload_data['file_name'];
      $width = $upload_data['image_width'];
      $height = $upload_data['image_height'];
      $config1 = array();
      $this-&gt;load-&gt;library('image_lib');
      $config1['source_image'] = site_path().'photos/'.$filename;
  
  
      $this-&gt;remove_existing_file($this-&gt;session-&gt;userdata('user_id'));
      $this-&gt;Profile_model-&gt;savephoto('Edit', $filename );
      redirect('/profile/photo');
  }
  </code></pre>
  
  <p>I am getting this error:</p>
  
  <blockquote>
    <p>The upload path does not appear to be valid.</p>
  </blockquote>