title: PHP Codeigniter Uploading Class, rename files with specific schema
body: <p>I am having a spot of trouble with Codeigniter and getting files to rename within the upload process from the Upload Library it has to offer. Now before anyone says it, I am not looking for "encrypted" file names.</p>
  
  <p>My Problem is in uploading images you have a good handful of types you could be dealing with. So how does one change the file name using the <code>file_name</code> config option to a specific schema (which I already have the schema part up and working). But maintain the same file type?</p>
  
  <p>Right now I am attempting</p>
  
  <p><code>$upload_config['file_name'] = $generated_filename_from_schema</code></p>
  
  <p>Only problem is <code>$generated_filename_from_schema</code> doesnt have a file extension, and leaving the file extension out of the equation CI seems to ignore it altogether and just takes the file and append_1, _2, _3 as it goes up if the files have the same name, otherwise it just leaves the name intact. </p>
  
  <p>Now I have to pass the <code>$config</code> to CI so it will upload the file, but how can I determin what kind of file I am working with before it trys to upload so I can use my name generation schema. </p>
  
  <p>*<strong><em>edit</em>*</strong></p>
  
  <pre><code>    $upload_config['upload_path'] = realpath(APPPATH.'../images/');
      $upload_config['allowed_types'] = 'gif|jpg|png';
      $upload_config['max_size']  = 0;
      $upload_config['max_width'] = 0;
      $upload_config['max_height'] = 0;
      $upload_config['remove_spaces'] = true;
  
      $upload_config['file_name'] = $this-&gt;genfunc-&gt;genFileName($uid);
  
      if($this-&gt;input-&gt;post('uploads'))
      {
  
          $this-&gt;load-&gt;library('upload');
          $this-&gt;upload-&gt;initialize($upload_config);
  
          if (!$this-&gt;upload-&gt;do_upload())
          {
              //echo 'error';
              echo $config['upload_path'];
              $this-&gt;data['errors'] = $this-&gt;upload-&gt;display_errors();
          }
          else
          {
              //echo 'uploaded';
              $this-&gt;data['upload_data'] = $this-&gt;upload-&gt;data();
          }
      }
  </code></pre>