文件名安全过滤
Upload Core_Upload::format_name( )
Upload
protected function format_name()
{
if ($this->filename)
{
$this->file['name'] = $this->filename;
}
else if ($this->config['rename'])
{
// 重命名文件
$ext = File::ext_by_mime($this->file['type']); // 获取文件后缀
$this->file['name'] = Text::random() . $ext;
}
else
{
// 对文件名做特殊字符过滤处理
$this->clean_filename();
if ($this->config['remove_spaces'])
{
$this->file['name'] = preg_replace('#\s+#', '_', $this->file['name']);
}
}
return $this;
}