Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8604861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:40:53+00:00 2026-06-12T02:40:53+00:00

I am having a spot of trouble with Codeigniter and getting files to rename

  • 0

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.

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 file_name config option to a specific schema (which I already have the schema part up and working). But maintain the same file type?

Right now I am attempting

$upload_config['file_name'] = $generated_filename_from_schema

Only problem is $generated_filename_from_schema 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.

Now I have to pass the $config 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.

*edit*

    $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->genfunc->genFileName($uid);

    if($this->input->post('uploads'))
    {

        $this->load->library('upload');
        $this->upload->initialize($upload_config);

        if (!$this->upload->do_upload())
        {
            //echo 'error';
            echo $config['upload_path'];
            $this->data['errors'] = $this->upload->display_errors();
        }
        else
        {
            //echo 'uploaded';
            $this->data['upload_data'] = $this->upload->data();
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:40:54+00:00Added an answer on June 12, 2026 at 2:40 am

    You can use $_FILES array to get original name of file.

    Extract extension of original file.Then, append to your new file name.

    Try as below

    $ext = end(explode(".", $_FILES[$input_file_field_name]['name']));
    $upload_config['file_name'] = $this->genfunc->genFileName($uid).'.'.$ext;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am having trouble getting this to work, can any one spot the issue?
I am having some trouble creating a nested association and I can't quite spot
I'm having a spot of bother getting anything to log with FirePHP and Zend
Having a spot of trouble with the following code. The method NextIPID() should simply
I'm having some trouble with date variables extracted from a masked textbox on a
I'm having trouble seeing why I'm getting an unresolved external symbol when creating an
I'm having a spot of trouble with a bit of code meant to find
I'm having a spot of trouble in making my functions work and my book
I'm having a spot of trouble with ASP.NET 4.0 memberships. I want to have
Im having trouble getting this to work, here´s a quick overview of the idea.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.