Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Check out CI's upload library:</p> <p><a href="http://www.codeigniter.com/user_guide/libraries/file_uploading.html" rel="nofollow noreferrer">http://www.codeigniter.com/user_guide/libraries/file_uploading.html</a></p> <p>Let's first take a look at how to do a simple file upload without changing the filename:</p> <pre><code>$config['upload_path'] = './uploads/'; $config['allowed_types'] = 'jpg|jpeg|gif|png'; $this-&gt;upload-&gt;initialize($config); if ( ! $this-&gt;upload-&gt;do_upload()) { $error = $this-&gt;upload-&gt;display_errors(); } else { $file_data = $this-&gt;upload-&gt;data(); } </code></pre> <p>It's that simple and it works quite well.</p> <p>Now, let's take a look at the meat of your problem. First we need to get the file name from the $_FILES array:</p> <pre><code>$file_name = $_FILES['file_var_name']['name']; </code></pre> <p>Then we can split the string with a <code>_</code> delimiter like this:</p> <pre><code>$file_name_pieces = split('_', $file_name); </code></pre> <p>Then we'll have to iterate over the list and make a new string where all except the first spot have uppercase letters:</p> <pre><code>$new_file_name = ''; $count = 1; foreach($file_name_pieces as $piece) { if ($count !== 1) { $piece = ucfirst($piece); } $new_file_name .= $piece; $count++; } </code></pre> <p>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:</p> <pre><code>$config['file_name'] = $new_file_name; </code></pre> <p>And that should do it! By default, CI has the <code>overwrite</code> $config param set to <code>FALSE</code>, 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.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload