title: Codeigniter - multiple file upload ->insert into db - having problems!
body: <p>I am using Codeigniter and I am trying to upload multiple files into a database.
  The files are seperate fields not multiple files for one field.</p>
  
  <p>I followed this post -<a href="http://codeigniter.com/forums/viewthread/110130/P0/" rel="nofollow noreferrer">http://codeigniter.com/forums/viewthread/110130/P0/</a></p>
  
  <p>I almost have it working but I am having some trouble with adding the uploaded data into my db.</p>
  
  <p>Here is my Controller function...</p>
  
  <pre><code>function addStation(){
          // set common properties
          $data['title'] = 'Add new station';
          $data['action'] = site_url('admin/station/addStation');
          $data['link_back'] = anchor('admin/station/index/','Back to list of stations',array('class'=&gt;'back'));
  
          // set validation properties
          $this-&gt;_set_fields();
          $this-&gt;_set_rules();
  
          $config['allowed_types'] = 'pdf|xls|doc|docx';
      $config['max_size'] = '1000';
      $config['max_width']  = '1024';
      $config['max_height']  = '768';
      $path_to_uploads='./uploads/files/stations';
      $config['upload_path'] = $path_to_uploads;
  
      // File specific (overrule global and optional)
  $config['logo_file']['upload_path']   = './uploads/images/stations';
  $config['logo_file']['allowed_types'] = 'gif|jpg|png';
  
  
      $this-&gt;load-&gt;library('upload', $config);
      //add this
      $this-&gt;upload-&gt;initialize($config);
  if (!$this-&gt;upload-&gt;do_upload(array('rajar_file','playlist_file','map_file', 'logo_file'))){
          $error = $this-&gt;upload-&gt;display_errors();
          echo "&lt;script&gt;alert($error);&lt;/script&gt;";
      }else{
          $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data(array('rajar_file','playlist_file','map_file', 'logo_file')));
  
          $rajar_file_name = $upload_data['rajar_file']['file_name'];
          $rajar_full_file_path = $path_to_uploads.'/'.$rajar_file_name;
  
           $playlist_file_name = $upload_data['playlist_file']['file_name'];
          $playlist_full_file_path = $path_to_uploads.'/'.$playlist_file_name;
  
           $map_file_name = $upload_data['map_file']['file_name'];
          $map_full_file_path = $path_to_uploads.'/'.$map_file_name;
  
           $logo_file_name = $upload_data['logo_file']['file_name'];
          $logo_full_file_path = $path_to_uploads.'/'.$logo_file_name;
      }
  
  // run validation
          if ($this-&gt;validation-&gt;run() == FALSE){
              $data['message'] = '';
          }else{
              // save data
              $station = array('name' =&gt; $this-&gt;input-&gt;post('name'),
                              'rajar' =&gt; $rajar_full_file_path,
                              'playlist' =&gt; $playlist_full_file_path,
                              'map' =&gt; $map_full_file_path,
                              'logo' =&gt; $logo_full_file_path    );
              $id = $this-&gt;stationModel-&gt;save($station);
  
              // set form input name="id"
              $this-&gt;validation-&gt;id = $id;
  
              // set user message
              $data['message'] = '&lt;div class="success"&gt;add new station success&lt;/div&gt;';
          }
  
            $this-&gt;template-&gt;set('title', 'Admin - Add New Station!');
        $this-&gt;template-&gt;load('admin/template', 'admin/stationEdit', $data);
  
  
      }
  </code></pre>
  
  <p>After the form is submitted I get the following errors...</p>
  
  <p>Message: Undefined variable: rajar_full_file_path</p>
  
  <p>Message: Undefined variable: playlist_full_file_path</p>
  
  <p>Message: Undefined variable: map_full_file_path</p>
  
  <p>Message: Undefined variable: logo_full_file_path</p>
  
  <p>Am I being daft, I can't figure it out?</p>
  
  <p>Thanks
  Dan</p>