title: Codeigniter Image Uploading not working online
body: <p>I have an application that neede photo upload, have done it in codeigniter, works perect on localhost, but it is not working online.</p>
  
  <p><strong>VIEW PAGE CODE :</strong></p>
  
  <pre><code>&lt;div&gt; 
                    &lt;form id="uploadimage" method="POST" name="uploadimage" action="&lt;?php echo base_url(); ?&gt;onebachhpan/savephoto" enctype="multipart/form-data"&gt;
                      &lt;input type="file" name="userfile" id="userfile" accept="image/*" /&gt;&lt;br/&gt;&lt;br/&gt;
                      &lt;input type="submit" class="button_example" id="upload_button" name="upload_button" value="Upload"/&gt;
               &lt;/form&gt;
               &lt;br/&gt;
               &lt;form  id="removeimage" method="POST" name="removeimage" action="&lt;?php echo base_url(); ?&gt;onebachhpan/removephoto" enctype="multipart/form-data"&gt;
                     &lt;input type="submit" style="position: absolute; left: 100px; top: 64px; " class="button_example" id="delete_button" name="delete_button" value="Delete"/&gt;
               &lt;/form&gt;
               &lt;/div&gt;
  </code></pre>
  
  <p>Following is the controller code for image upload:
  This is working fine on localhost:</p>
  
  <p><strong>CONTROLLER CODE:</strong></p>
  
  <pre><code>function savephoto()
      {
           $this-&gt;load-&gt;library('session');
          $this-&gt;load-&gt;library('image_lib');
          $config['image_library'] = 'gd2';
          $config['upload_path'] = './profilepic/'; //location to store image
          $config['allowed_types'] = 'gif|jpg|png';
          $this-&gt;load-&gt;library('upload', $config);
          if ( ! $this-&gt;upload-&gt;do_upload('userfile'))
          {
              $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
           redirect(base_url().'uploaderror');
  
  
          }
          else
          {
              $photo = $this-&gt;upload-&gt;data();
              $data['photo'] = $photo;    
              $id = $this-&gt;session-&gt;userdata('MemberId');
              $filename = $photo['file_name'];
              $extension = $photo['file_ext'];
  
              $this-&gt;load-&gt;model('profile_model');
              $this-&gt;profile_model-&gt;photo($extension,$id);
  
  
  
            // echo "&lt;pre&gt;";print_r($photo);
              $newpath = './profilepic/'.$id.$extension;
  
              $config['source_image'] = './profilepic/'.$filename;
              $config['overwrite']=true;
  
              $config['new_image'] = $newpath;
  
              $config['width']  = '170';
              $config['height']  = '240';
              $config['maintain_ratio'] = true;
  
  
              //$this-&gt;load-&gt;library('image_lib', $config);
  
              $this-&gt;image_lib-&gt;initialize($config);
              $this-&gt;image_lib-&gt;resize();
              unlink('./profilepic/'.$filename);
              //$this-&gt;load-&gt;view('onebachhpan_index');
              redirect(base_url().'profile');
  
          }   
      }
  </code></pre>