Replacement for File::mime() in Laravel 4 (to get mime type from file extension)

后端 未结 5 1023
名媛妹妹
名媛妹妹 2020-12-06 17:20

Laravel 3 had a File::mime() method which made it easy to get a file\'s mime type from its extension:

$extension = File::extension($path);
$         


        
5条回答
  •  孤街浪徒
    2020-12-06 18:22

    public function mimeType($path)
    {
        return finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path);
    }
    

    Ref: https://github.com/illuminate/filesystem/blob/master/Filesystem.php#L194

提交回复
热议问题