title: Codeigniter after renaming file for upload how do i save the new file name to my database
body: <p>I have an issue with codeigniter file upload library. I am trying to upload multiple files (7 images), i renamed them and after which uploaded to my server file system. But i cannot get the new name to save in my database.</p>
  
  <p>Here is my Controller</p>
  
  <pre><code>if (isset($_POST['carform']))
  {
                  $dir = './uploads/cars';
                  $config['upload_path'] = $dir;
                  $config['allowed_types'] = 'jpg|jpeg|png';
                  $config['max_size'] = '2048';
                  $config['max_width']  = '1024';
                  $config['max_height']  = '768';
                  $config['remove_spaces'] = 'TRUE';
                  $uid = $this-&gt;tank_auth-&gt;get_user_id();
                  $config['file_name'] = time().$uid;
                  $this-&gt;load-&gt;library('upload', $config);
  
              foreach($_FILES as $field =&gt; $file)
              {
  
                  if($file['error'] == 0)
                  {
  
                      // So lets upload
                      if ($this-&gt;upload-&gt;do_upload($field))
                      {
  
  
                          $data = array('upload' =&gt; $this-&gt;upload-&gt;data());
  
                          $this-&gt;cars_model-&gt;set_car($data);//end foreach loop.....
                          $id = $this-&gt;db-&gt;insert_id();
                  redirect('/cars/details/'.$id.'');
  
                      }else
                      {
                          $errors = $this-&gt;upload-&gt;display_errors();
                          echo($errors);
                      }
                  }
  
              }
  
  
          }//end if  statement ...
  </code></pre>