title: Codeigniter Rename file on upload
body: <p>I'm trying to add time as the prefix of the image name along with the original name when uploading, But I couldn't figure it out. Please help me with the following code to add a prefix to my original file name when uploading.</p>
  
  <pre><code>&lt;?php
  
  class Upload extends CI_Controller {
  
      function __construct()
      {
          parent::__construct();
          $this-&gt;load-&gt;helper(array('form', 'url'));
      }
  
      function index()
      {
          $this-&gt;load-&gt;view('upload_form', array('error' =&gt; ' ' ));
      }
  
      function do_upload()
      {
  
  
          $config['upload_path'] = 'Public/uploads/';
          $config['allowed_types'] = 'gif|jpg|png';
          $config['max_size'] = '1024';
          $config['max_width']  = '1024';
          $config['max_height']  = '768';
  
  
  
          $this-&gt;load-&gt;library('upload', $config);
  
  
          if ( ! $this-&gt;upload-&gt;do_upload())
          {
              $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>