title: Upload multiple file using codeignter with ajax jquery
body: <p>I want to upload multiple files at a time in Codeigniter using jquery ajax, single upload is working but am trying to upload multiple files but getting this error:</p>
  <blockquote>
  <p>You did not select a file to upload</p>
  </blockquote>
  <p>for single selection this code was working but i have only added array type to file field not it is throwing the above error, Any suggestion to solve this issue.</p>
  <p><strong>Controller Code:-</strong></p>
  <pre><code> public function do_upload()
      {
          if (($_SERVER['REQUEST_METHOD']) == &quot;POST&quot;) {
              for($i=0; $i&lt;count($_FILES['attach_file']['name']); $i++){
              $filename = $_FILES['attach_file']['name'][$i];
              $filename = strstr($filename, '.', true);
              $email    = $this-&gt;session-&gt;userdata('email');
              $filename = strstr($email, '@', true).&quot;_&quot;.$filename;
              $filename = strtolower($filename);
  
              $config['upload_path']   = FCPATH .'./assets/attachments/';
              $config['allowed_types'] = 'pdf|doc|docx|bmp|gif|jpg|jpeg|jpe|png';
              $config['max_size']      = 0;
              $config['max_width']     = 0;
              $config['max_height']    = 0;
     
              $this-&gt;load-&gt;library('upload', $config);
  
              $name = 'attach_file[]';
              if ( ! $this-&gt;upload-&gt;do_upload($name) ) {
                  $data['exception'] = $this-&gt;upload-&gt;display_errors();
                  $data['status'] = false;
                  echo json_encode($data);
              } else {
                  $upload =  $this-&gt;upload-&gt;data();
                  $data['message'] = 'Uploaded successfully';
                  $data['filepath'] = './assets/attachments/'.$upload['file_name'];
                  $data['status'] = true;
                  echo json_encode($data);
              }
          }  
          }
      } 
  </code></pre>
  <p><strong>View:-</strong></p>
  <pre><code> &lt;?php echo form_open_multipart('form','class=&quot;form-inner&quot; id=&quot;userForm&quot; ') ?&gt;
    &lt;input type=&quot;file&quot; name=&quot;attach_file[]&quot; id=&quot;attach_file&quot;
    multiple=&quot;true&quot;&gt;
  </code></pre>
  <p><strong>Jquery:</strong></p>
  <pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
  $(function(){
      var browseFile = $('#attach_file');
      var form       = $('#userForm');
      var progress   = $(&quot;#upload-progress&quot;);
      browseFile.on('change',function(e)
      {
          e.preventDefault(); 
          uploadData = new FormData(form[0]);
  
          $.ajax({
              url      : '&lt;?php echo base_url('do_upload') ?&gt;',
              type     : form.attr('method'),
              dataType : 'json',
              cache    : false,
              contentType : false,
              processData : false,
              data     : uploadData, 
              beforeSend  : function() 
              {
                
              },
              success  : function(data) 
              { 
                
              }, 
              error    : function() 
              {
              }   
          });
      });
  });
  </code></pre>