Changing the name of the downloaded file in CodeIgniter (periods and underscores)

I am having problems changing the name of the downloaded file:

$config = array( 'allowed_types' => 'mp3', 'file_name' => $fulltitle, // Lets say we've entered 'asdfmp3' 'upload_path' => './music/' ); $this->load->library('upload', $config); $this->upload->do_upload(); 

But when I check my file name, it shows me

a.s_.d_.f_.mp3

Why does CodeIgniter add an underscore before each dot after the first? How can I disable this? Thanks.

ADDED

Well, I found a solution. system-> libraries-> Upload.php.

Line function 994, _prep_filename ().

  $parts = explode('.', $filename); $ext = array_pop($parts); $filename = array_shift($parts); foreach ($parts as $part) { if ( ! in_array(strtolower($part), $this->allowed_types) OR $this->mimes_types(strtolower($part)) === FALSE) { $filename .= '.'.$part.'_'; // Line 994 } else { $filename .= '.'.$part; } } 
+6
source share
1 answer

Try adding 'remove_spaces' => FALSE to your configuration array and see if this problem cares. The default value is TRUE, but this should be a replacement for spaces with underscores. It could be a CI error with the file upload class.

+3
source

Source: https://habr.com/ru/post/886301/


All Articles