选择语言 :

 Core_Upload::format_name

文件名安全过滤

Upload Core_Upload::format_name( )
返回值
  • Upload
File: ./core/classes/upload.class.php
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
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;
}