title: Codeigniter upload file name
body: <p>Usually we can get the form data in <code>Codeigniter</code> by using <code>$this-&gt;input-&gt;get('field_name')</code> or <code>$this-&gt;input-&gt;post('field_name')</code> and that's fine.</p>
  
  <p>In raw <code>PHP</code> we use <code>$_FILES["fileToUpload"]["name"]</code> to get the file name that the user trying to upload.</p>
  
  <p>My question is: Is there any <code>Codeigniter</code> way to get the name of the file that needs to be uploaded?</p>
  
  <p>I am trying to say that i need to get the file name that the user is trying to upload before trying to save it in my server using <code>Codeigniter</code> library instead of using raw <code>PHP</code> global <code>$_FILES</code> variable.</p>
  
  <pre><code>&lt;?php
  
  class Upload extends CI_Controller {
  
          public function __construct()
          {
                  parent::__construct();
                  $this-&gt;load-&gt;helper(array('form', 'url'));
          }
  
          public function index()
          {
                  $this-&gt;load-&gt;view('upload_form', array('error' =&gt; ' ' ));
          }
  
          public function do_upload()
          {
                  $config['upload_path']          = './uploads/';
                  $config['allowed_types']        = 'gif|jpg|png';
                  $config['max_size']             = 100;
                  $config['max_width']            = 1024;
                  $config['max_height']           = 768;
  
                  $this-&gt;load-&gt;library('upload', $config);
  
                  // get the user submitted file name here
  
                  if ( ! $this-&gt;upload-&gt;do_upload('userfile'))
                  {
                          $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
  
                          $this-&gt;load-&gt;view('upload_form', $error);
                  }
                  else
                  {
                          $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data());
  
                          $this-&gt;load-&gt;view('upload_success', $data);
                  }
          }
  }
  ?&gt;
  </code></pre>