title: Codeigniter: how to get a filename of a file
body: <p>i am a Codeigniter rookie and i am trying to get the file name of an uploaded image so that i can save it in the database.
   i have two models, homemodel deals with my database and the image_upload_model deals with image uploading.
  Everything works fine except i dont know how to post the image filename to the database </p>
  
  <p><strong>image_upload_model.php</strong></p>
  
  <pre><code>&lt;?php
  
  class Image_upload_model extends CI_Model {
  
      var $image_path;
  
      //constructor containing the image path
      function Image_upload_model() {
  
          $this-&gt;image_path = realpath(APPPATH.'../assets/img');
      }
  
      //uploading the file
      function do_upload() {
  
          $config = array(
              'allowed_types' =&gt; 'jpg|jpeg|gif|png',
              'upload_path' =&gt; $this-&gt;image_path
          );
          $this-&gt;load-&gt;library('upload',$config);
          $this-&gt;upload-&gt;do_upload();
      }
  }
  ?&gt;
  </code></pre>
  
  <p><strong>homemodel.php</strong></p>
  
  <pre><code>&lt;?php
  
  class homeModel extends CI_Model {
  
      //inserting into the table tenants
      function addTenants() {
  
          $this-&gt;load-&gt;model('Image_upload_model');
  
          $data = array(
              'Fname' =&gt; $this-&gt;input-&gt;post('Fname'),
              'Lname' =&gt; $this-&gt;input-&gt;post('Lname'),
              'contact' =&gt; $this-&gt;input-&gt;post('contact'),
              'email' =&gt; $this-&gt;input-&gt;post('email'),
              'location' =&gt; $this-&gt;input-&gt;post('location'),
              'img_url' =&gt; " "//the filename of the image should go here
          );
  
          $this-&gt;db-&gt;insert('tenants', $data);
      }
  }
  ?&gt;
  </code></pre>
  
  <p>The controller<br/>
  <strong>homecontroller.php</strong></p>
  
  <pre><code>&lt;?php
  
  class HomeController extends CI_Controller {
  
      public function index() {
  
          $this-&gt;load-&gt;helper('form');
          $this-&gt;load-&gt;helper('html');
          $this-&gt;load-&gt;model('homemodel');
          $this-&gt;load-&gt;model('Image_upload_model');
  
          if ($this-&gt;input-&gt;post('submit') == 'Submit') {
  
              $this-&gt;homemodel-&gt;addTenants();
              echo 'inserted';
              $this-&gt;Image_upload_model-&gt;do_upload();
              echo 'image uploaded';
          }
          $this-&gt;load-&gt;view('index.php');
      }
  }
  ?&gt;
  </code></pre>
  
  <p>any help is appreciated, thank you!</p>