title: CodeIgniter AJAX file not uploading
body: <p>My form in view is </p>
  
  <pre><code>&lt;?php 
        $attributes = array('id' =&gt; 'myForm');
        echo form_open_multipart('', $attributes); ?&gt;
  
      &lt;div class="form-group"&gt;
          &lt;label for="image"&gt;Main Image&lt;/label&gt;
          &lt;input type="file" class="form-control-file" id="image" name="image" aria-describedby="fileHelp"&gt;
      &lt;/div&gt;
  
      &lt;div style="text-align:center"&gt;
          &lt;button type="button" class="btn btn-primary" id="add"&gt;ADD&lt;/button&gt;
          &lt;button type="reset" class="btn btn-primary"&gt;Reset&lt;/button&gt;
      &lt;/div&gt;
  &lt;?php echo form_close(); ?&gt;     
  </code></pre>
  
  <p>And my script is as follows </p>
  
  <pre><code>&lt;script&gt;
  
      $("#add").click(function () {
  
          var image = $("#image").val() ;
  
          $.ajax({
              type: "POST",
              url: "&lt;?php echo site_url('form/addArticleData'); ?&gt;",
              data: { 
  
                  image: image,
  
              },
              dataType: "html",
              contentType: false,
              cache: false,
              processData: false,
              success: function(data) {
                  if(data) {
                      alert($.trim(data));
                      $("#myForm")[0].reset();
                  } else {
                      alert("Some Error Occurred. Please Try Again!!!");
                  }
              }, error: function() {
                  alert("ERROR!");
              }
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>And my addArticleData function inside the controller form contains</p>
  
  <pre><code>if(isset($_FILES["image"]["name"]))  
      { 
          $config = array(
              'upload_path' =&gt; "images",
              'allowed_types' =&gt; "*",
              'overwrite' =&gt; TRUE,
              'max_size' =&gt; "2048000", // Can be set to particular file size , here it is 2 MB(2048 Kb)
              'max_height' =&gt; "768",
              'max_width' =&gt; "1024"
          );
          $this-&gt;load-&gt;library('upload', $config);
          if($this-&gt;upload-&gt;do_upload('image'))
          {
              $data = array(
  
                  'image' =&gt; $this-&gt;input-&gt;post('image')
  
              );
              //print_r($data);
              if($this-&gt;modal-&gt;insert($data, 'admin')) {
                  echo "DATA INSERTED SUCCESSFULLY";
              }
          }
          else {
              echo "ERROR";
          }
      } else {
          echo "FILE NOT SET";
      }
  </code></pre>
  
  <p>The problem is that whenever I tried to execute this script it alerts FILE NOT SET. And if I print $_FILES using print_r($_FILES);exit; it alerts an empty array. </p>
  
  <p>Further if I try commented print_r($data);exit; and remove all the lines preceding it then  it alerts the name of the image uploaded as C:\fakepath\image.png</p>
  
  <p>I just can't understand why this is not working. Please HELP </p>