title: i have a working multiple upload (document and image) CODEIGNITER
body: <p>I have made a working multiple upload in codeigniter but I'm having a problem on how am I gonna insert the file names of those files on two tables (documents and images table) which these two tables have two the same column name (ID, name). is there way that i could disjunct or compart my code for uploading image and doc. because I united them in one function.</p>
  
  <p>here is my CODE. it is working.</p>
  
  <p>VIEW</p>
  
  <pre><code>&lt;?php echo form_open_multipart('test'); ?&gt;
     &lt;label&gt;Images&lt;/label&gt;
        &lt;input type='file' multiple='multiple' name='userfile[]'&gt;
     &lt;label&gt;Documents&lt;/label&gt;
        &lt;input type='file' multiple='multiple' name='userfile[]'&gt;
  &lt;?php echo form_submit('submit', 'Upload them files!') ?&gt;
  </code></pre>
  
  <p>CONTROLLER</p>
  
  <pre><code>function index()
  {
      if (isset($_POST['submit']))
      {
          $this-&gt;load-&gt;library('upload');
          //$this-&gt;uploadfile($_FILES['userfile']);
          $files = $_FILES;
          $cpt = count($_FILES['userfile']['name']);
          for($i=0; $i&lt;$cpt; $i++)
          {   
  
                  $filename = $_FILES['userfile']['name']= $files['userfile']['name'][$i];
                  $_FILES['userfile']['type']= $files['userfile']['type'][$i];
                  $_FILES['userfile']['tmp_name']= $files['userfile']['tmp_name'][$i];
                  $_FILES['userfile']['error']= $files['userfile']['error'][$i];
                  $_FILES['userfile']['size']= $files['userfile']['size'][$i]; 
  
  
                  $this-&gt;upload-&gt;initialize($this-&gt;set_upload_options());
                  $this-&gt;upload-&gt;do_upload();
                  $this-&gt;upload-&gt;data();
          }
      }
  $this-&gt;load-&gt;view("test");
  }
  private function set_upload_options()
  {   
  //  upload an image and document options
      $config = array();
      $config['upload_path'] = './upload_documents/';
      $config['allowed_types'] = 'jpg|png|gif|jpeg|JPG|PNG|GIF|JPEG|pdf|doc|docx|xls|xlsx';
      $config['max_size'] = '0'; // 0 = no file size limit
      $config['max_width']  = '0';
      $config['max_height']  = '0';
      $config['overwrite'] = TRUE;
  
  
      return $config;
  }
  </code></pre>
  
  <p>These codes are working and it is able to transfer all the files on my desired path.
  but I was wondering on making the MODEL, how am I gonna identify the file type as you seen my codes above I passed the name of the file on a variable "$filename". If you use print_r($filename), you'll see all the file name and it's file extension. Those names is the one that I will insert to my two tables accordingly to their type of file.</p>
  
  <p>Is there any code for CodeIgniter or PHP code that I will use to identify the file type and pass it to the model with two function like upload_image or upload_docu? Help please. </p>