title: Codeigniter 2.1 - fileupload You did not select a file to upload
body: <p>Model function:</p>
  
  <pre><code>public function file_upload($folder, $allowed_type, $max_size = 0, $max_width = 0, $max_height = 0)
      {
          $folder = $this-&gt;path . $folder;
  
          $files = array();
          $count = 0;
  
          foreach ($_FILES as $key =&gt; $value) :
  
              $file_name = is_array($value['name']) ? $value['name'][$count] : $value['name'];
              $file_name = $this-&gt;global_functions-&gt;char_replace($file_name, '_');
                  $count++;
                  $config = array(
                  'allowed_types' =&gt; $allowed_type,
                  'upload_path'   =&gt; $folder,
                  'file_name'     =&gt; $file_name,
                  'max_size'      =&gt; $max_size,
                  'max_width'     =&gt; $max_width,
                  'max_height'    =&gt; $max_height,
                  'remove_spaces' =&gt; TRUE
                   );
  
          $this-&gt;load-&gt;library('image_lib');
              $this-&gt;image_lib-&gt;clear();
              $this-&gt;load-&gt;library('upload');
              $this-&gt;upload-&gt;initialize($config);
  
              if (!$this-&gt;upload-&gt;do_upload($key)) :
                  $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
              var_dump($error);
                  return FALSE;
              else :
                  $file = $this-&gt;upload-&gt;data();
                  $files[] = $file['file_name'];
              endif;
  
          endforeach;
  
          if(empty($files)):
              return FALSE;
          else:
              return implode(',', $files);
          endif;
      }
  </code></pre>
  
  <p>This function is working partially. Files are being uploaded to the selected folder, but I am getting this error: <strong>You did not select a file to upload.</strong> and getting <strong>FALSE</strong> as a result? What seems to be a problem? (form is using <strong>form_open_multipart</strong>) </p>