title: Codeigniter multiple upload of different file-types
body: <p>I want to upload an audio file and an image in the same form and store their names in the db...what happens is only one of the files is uploaded (the one that is first in row)
  the other gives an error of not allowed type</p>
  
  <p>here is my view:</p>
  
  <pre><code>        &lt;?php echo form_open_multipart('index.php/ena_dyo_edit');?&gt;
          Title:&lt;input type='text' name="title" size="40" id="title" /&gt;
          &lt;p&gt;Title Photo:&lt;input type="file" name="title_photo" size="20" id="title_photo" /&gt;&lt;/p&gt;
          &lt;p&gt;Body:&lt;textarea name="body" rows = "10" cols="60" id="body"&gt;&lt;/textarea&gt;&lt;p&gt;
          &lt;p&gt;Soundfile:&lt;input type="file" name="soundfile" size="20" id="soundfile" /&gt;&lt;/p&gt;
          &lt;p&gt;Author:&lt;input type="text" name="author" size="40" id="author"/&gt;&lt;/p&gt;
          &lt;p&gt;&lt;input type="submit" value="Submit New Post"/&gt;&lt;/p&gt;
          &lt;?php echo form_close(); ?&gt;
  </code></pre>
  
  <p>and here are my model functions:</p>
  
  <pre><code>function soundfile_upload($userfile = 'userfile'){
      //uploads a sound file
  
       $config = array(
              'upload_path' =&gt; './uploads/soundfiles/',
              'allowed_types' =&gt; 'mp3|wav|aif|aiff|ogg',
              'max_size' =&gt; '256000' //250 MB max size
          );
  
  
        $this-&gt;load-&gt;library('upload', $config);
  
         if (!$this-&gt;upload-&gt;do_upload($userfile)) {
              $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
  
              $this-&gt;load-&gt;view('upload_error', $error);
          }
  
        else{
  
             $soundfile_data = $this-&gt;upload-&gt;data();
             $entry_title = $this-&gt;input-&gt;post('title'); //using the name of the post to relate the audio file
             $entry_id = $this-&gt;db-&gt;insert_id(); //the id of our last entry!
  
             //create array to load to database
             $insert_data = array(
                  'soundfile' =&gt; $soundfile_data['file_name']
                 );
  
              //$this-&gt;db-&gt;where('id', $entry_id);
              $this-&gt;db-&gt;update('entries', $insert_data,array('id' =&gt; $entry_id));  //load array to database
        }
  
  
  
    }
  
    function title_photo_upload($userfile = 'userfile'){
      //uploads a photo for a post title
  
       $config = array(
              'upload_path' =&gt; './uploads/title_photos/',
              'allowed_types' =&gt; 'jpg|jpeg|gif|png',
              'max_size' =&gt; '256000' //250 MB max size
          );
  
  
        $this-&gt;load-&gt;library('upload', $config);
  
         if (!$this-&gt;upload-&gt;do_upload($userfile)) {
              $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
  
              $this-&gt;load-&gt;view('upload_error', $error);
          }
  
        else{
  
             $soundfile_data = $this-&gt;upload-&gt;data();
             $entry_id = $this-&gt;db-&gt;insert_id(); //the id of our last entry!
  
             //create array to load to database
             $insert_data = array(
                  'title_photo' =&gt; $soundfile_data['file_name']
                 );
  
  
              $this-&gt;db-&gt;update('entries', $insert_data,array('id' =&gt; $entry_id));  //load picture where id = entry_id
  
  
  
    }
  }
  </code></pre>