title: codeigniter upload file error
body: <p>I am receiving the error "You did not select a file to upload." When I am attempting to upload a photo using this code:</p>
  
  <pre><code>function index()
  {
  $this-&gt;load-&gt;helper(array('form', 'url'));
  $this-&gt;load-&gt;library('session');
  $this-&gt;load-&gt;library('form_validation');
  $this-&gt;form_validation-&gt;set_rules('title', 'title', 'trim|required|max_length[255]');
  $this-&gt;form_validation-&gt;set_rules('description', 'description', 'trim|required|max_length[2550]');
  $this-&gt;form_validation-&gt;set_error_delimiters('&lt;p class="error"&gt;', '&lt;/p&gt;');
  
  $data['title'] = $this-&gt;input-&gt;post('username');
  $data['description'] = $this-&gt;input-&gt;post('description');
  if($this-&gt;form_validation-&gt;run() == FALSE)
  {
    $this-&gt;load-&gt;view('upload_form', $data);
  }
  else
  {
    $this-&gt;load-&gt;helper('string');
    $config['upload_path'] = realpath($_SERVER['DOCUMENT_ROOT'] . '/uploads') . '/';
    $config['allowed_types'] = 'gif|jpg|png';
    $config['max_size'] = '5000';
    $config['max_width'] = '10240';
    $config['max_height'] = '10240';
    $config['overwrite'] = FALSE;
    $config['file_name'] =  random_string('alpha', 6);
    $config['remove_spaces'] = TRUE;
  
    $this-&gt;load-&gt;library('upload', $config);
  
    if(!$this-&gt;upload-&gt;do_upload('file'))
    {
      $error = array('upload_message' =&gt; $this-&gt;upload-&gt;display_errors());
      $this-&gt;load-&gt;view('upload_form', $error);
    }
    else
    {
      //do upload stuff
    }
  }
  </code></pre>
  
  <p>And this is the view:</p>
  
  <pre><code>&lt;?php echo form_open('upload'); ?&gt;
  &lt;h5&gt;Title: &lt;/h5&gt;
  &lt;br /&gt;
  &lt;?php echo form_input('title', set_value('title')); ?&gt;
  &lt;?php $a = form_error('title'); ?&gt;
  &lt;br /&gt;
  &lt;?php echo '&lt;h5&gt;'; echo $a=="" ? '&lt;br /&gt;' : $a.'&lt;br /&gt;'; echo '&lt;/h5&gt;'; ?&gt;
  &lt;h5&gt;Description: &lt;/h5&gt;
  &lt;br /&gt;
  &lt;?php echo form_textarea('description', set_value('description')); ?&gt;
  &lt;?php $a = form_error('description'); ?&gt;
  &lt;br /&gt;
  &lt;?php echo '&lt;h5&gt;'; echo $a=="" ? '&lt;br /&gt;' : $a.'&lt;br /&gt;'; echo '&lt;/h5&gt;'; ?&gt;
  &lt;h5&gt;Upload: &lt;/h5&gt;
  &lt;br /&gt;
  &lt;?php echo form_upload('file'); ?&gt;
  &lt;?php $a = (isset($upload_message) ? $upload_message : "&lt;br/&gt;&amp;nbsp&lt;br /&gt;&lt;br /&gt;"); ?&gt;
  &lt;?php echo '&lt;h5&gt;'; echo $a=="" ? '&lt;br /&gt;a' : $a.''; echo '&lt;/h5&gt;'; ?&gt;
  &lt;br /&gt;
  &lt;?php echo form_submit('upload', 'Upload'); ?&gt;
  &lt;?php form_close(); ?&gt;
  </code></pre>
  
  <p>I have made a test upload form with the same config and it works perfectly. When I try and use this form however, I am receiving the error "You did not select a file to upload."</p>