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 3318540
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:43:04+00:00 2026-05-17T22:43:04+00:00

Using CodeIgniter, I am trying to modify the name of the uploaded file to

  • 0

Using CodeIgniter, I am trying to modify the name of the uploaded file to camelCase by removing any spaces and capitalizing subsequent words.

I am pretty sure that I can rename the file using the second parameter of move_uploaded_file but I don’t even know where to look to figure out how to modify the name to camelCase.

Thanks in advance!
Jon

  • 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-05-17T22:43:05+00:00Added an answer on May 17, 2026 at 10:43 pm

    Check out CI’s upload library:

    http://www.codeigniter.com/user_guide/libraries/file_uploading.html

    Let’s first take a look at how to do a simple file upload without changing the filename:

    $config['upload_path']   = './uploads/';
    $config['allowed_types'] = 'jpg|jpeg|gif|png';
    
    $this->upload->initialize($config);
    
    if ( ! $this->upload->do_upload())
    {
        $error = $this->upload->display_errors();
    }   
    else
    {
        $file_data = $this->upload->data();
    }
    

    It’s that simple and it works quite well.

    Now, let’s take a look at the meat of your problem. First we need to get the file name from the $_FILES array:

    $file_name = $_FILES['file_var_name']['name'];
    

    Then we can split the string with a _ delimiter like this:

    $file_name_pieces = split('_', $file_name);
    

    Then we’ll have to iterate over the list and make a new string where all except the first spot have uppercase letters:

    $new_file_name = '';
    $count = 1;
    
    foreach($file_name_pieces as $piece)
    {
        if ($count !== 1)
        {
            $piece = ucfirst($piece);
        }
    
        $new_file_name .= $piece;
        $count++;
    }
    

    Now that we have the new filename, we can revisit what we did above. Basically, you do everything the same except you add this $config param:

    $config['file_name'] = $new_file_name;
    

    And that should do it! By default, CI has the overwrite $config param set to FALSE, so if there are any conflicts, it will append a number to the end of your filename. For the full list of parameters, see the link at the top of this post.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.