1.首先修改think/library/think/下面的file.php文件有个设置文件名的方法,修改成以下:
public function setSaveName($saveName)
{
$saveName = iconv('gb2312', 'utf-8',$saveName);//增加的转码
$this->saveName = $saveName;
return $this;
}
2.数据库的编码格式建议统一设为utf8_general_ci(不区分大小写)
3.获取原保存的文件名:$file->getInfo()['name']
4.在原文件file类中找到move方法
因为保存的时候使用的是utf-8但是用于保存在硬盘上的目录需要使用的是gbk编码
所以需要转码,
返回文件名的时候 需要把gbk的编码转回utf8,不然可能会报错。