Codeigniter Rename file on upload

后端 未结 9 2317
暗喜
暗喜 2020-12-13 09:28

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

相关标签:
9条回答
  • 2020-12-13 10:14

    Try This:

    $config['file_name'] = "yourCustomFileName";
    
    0 讨论(0)
  • 2020-12-13 10:17

    If your $config is with this code: $config['encrypt_name'] = TRUE; the name of your file will be forced to rename with a encrypt name, just remove the code.

    0 讨论(0)
  • 2020-12-13 10:24

    when you use do_upload() function its rename file name if already exists and upload file

    System->libraries->Upload.php

    default function of do_upload() return true or false replace

    return $this->upload_path.$this->file_name;

    and in another file

     <input type='file' name='userfile'/>
    
    
    <?php
        $upload_file_name = $this->upload->do_upload('userfile');
                    $finalname;
                    if (!$upload_file_name) {
                        $finalname = 'default.png';
                    } else {
    
                        $split_data_upload_file_name = explode("/", $upload_file_name);
                        foreach ($split_data_upload_file_name as $i => $value) {
    
                            $finalname = $value;
                        }
                    }
    
    ?>
    
    0 讨论(0)
提交回复
热议问题