Blogger Information
Blog 43
fans 2
comment 2
visits 113120
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
thinkphp.5.1 上传保存为中文文件问题
朝游东海
Original
1736 people have browsed it

参考文件  https://www.php.cn/blog/detail/1658.html

        $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
        // 文件保存命名规则
        $saveName = $this->buildSaveName($savename, $autoAppendExt);
        //http://phpshiti.com/article/110
        //https://www.php.cn/blog/detail/1658.html
        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            $saveName = iconv('utf-8','gb2312//IGNORE', $saveName);
        }



//调用move()方法后,获取的中文文件名乱码
$info->getSaveName()

解决方法

   //https://www.php.cn/blog/detail/1658.html
$filename = $info->getSaveName();

$exclePath = iconv("GB2312","UTF-8",  $filename);

(
    [title] => 第三法规库文件1.docx
    [size] => 7.13
    [type] => docx
    [ext] => .docx
    [path] => \uploads\statute\第三法规库文件1.docx
    [role_id] => 8
)

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post