代码之家  ›  专栏  ›  技术社区  ›  VinZ

SplFileInfo::getSize在文件名包含特殊字符(俄语、中文…)时不起作用

  •  0
  • VinZ  · 技术社区  · 6 年前

    我有一个函数尝试检索上传文件的大小,但当文件名包含特殊字符(如法语、俄语或中文字符)时,该函数失败:

    • 5b99109c1a10eèé·§·.pdf
    • 5b99140a5a47d_手册CVI3(法语§ais).pdf

    SplFileInfo::getSize():C:\wamp\www\DESiwid\app/。/web/uploads/documents\5b99104337d6b_K°°2016.pdf的stat失败

    这是我的代码:

    /**
     * @param Document $document
     * @return int
     */
    private function getSize(Document $document)
    {
        /* retrieve Symfony\Component\HttpFoundation\File\File $file from entity */
        $file = $document->getFileFile();
        /* return file size */
        return $file->getSize();
    }
    
    0 回复  |  直到 6 年前