我在更改上传文件的名称时遇到了一些问题:
$config = array(
'allowed_types' => 'mp3',
'file_name' => $fulltitle, // Lets say we've entered 'a.s.d.f.mp3'
'upload_path' => './music/'
);
$this->load->library('upload', $config);
$this->upload->do_upload();
但是,当我查看我的文件名时,它会显示给我
a.s_.d_.f_.mp3
为什么CodeIgniter在第一个点之后的每个点之前添加下划线?我怎么能禁用这个?谢谢.
添加
我找到了解决方案.system-> libraries-> Upload.php文件.
第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;
}
}