title: Upload multiple files in CodeIgniter
body: <p>In my CodeIgniter project I'm uploading files during the project creation. Here's the uploading function:</p>
  
  <pre><code>function uploadFiles(){
  
       $this-&gt;load-&gt;library('upload');  
       $error = 0;    
       $projectName = $_POST['projectname'];
       mkdir('./uploads/'.$projectName);
  
       for($i=0; $i&lt;count($_FILES); $i++)
       {
  
         $_FILES['userfile']['name']    = $_FILES['files']['name'][$i];
         $_FILES['userfile']['type']    = $_FILES['files']['type'][$i];
         $_FILES['userfile']['tmp_name'] = $_FILES['files']['tmp_name'][$i];
         $_FILES['userfile']['error']       = $_FILES['files']['error'][$i];
         $_FILES['userfile']['size']    = $_FILES['files']['size'][$i];
  
         $config['upload_path']   = './uploads/'.$projectName;
         $config['allowed_types'] = 'xml|etl';
         $config['max_size']      = '0';
         $config['overwrite']     = TRUE;
  
        $this-&gt;upload-&gt;initialize($config);
  
        if($this-&gt;upload-&gt;do_upload())
        {
          $error += 0;
        }else{
          $error += 1;
        }
       }
  
       if($error &gt; 0){ return FALSE; }else{ return TRUE; }
  
  }
  </code></pre>
  
  <p>And I call this function in the create_project function like this:</p>
  
  <pre><code>public function create_project() {
      $this-&gt;load-&gt;library('form_validation');
  
      $this-&gt;form_validation-&gt;set_rules('projectname', 'Project name', 'required');
  
      $this-&gt;form_validation-&gt;set_message('required', 'This is an obligatory field');
  
      if($this-&gt;form_validation-&gt;run() == FALSE) {
          $this-&gt;load-&gt;view('project_creation_view');
      } else {
          $this-&gt;load-&gt;model('Project_management_model');
          $this-&gt;Project_management_model-&gt;create_project();
          $this-&gt;uploadFiles();
      }
  }
  </code></pre>
  
  <p>However this does not do anything. The files are not being uploaded. Even an empty directory is not being created. Could anybody help me to find the error?</p>
  
  <p>Thanks.</p>