helpers\BaseFileHelper getMimeType()

getMimeType() public static method

Determines the MIME type of the specified file.

This method will first try to determine the MIME type based on finfo_open. If the fileinfo extension is not installed, it will fall back to getMimeTypeByExtension() when $checkExtension is true.

public static string getMimeType ( $file, $magicFile = null, $checkExtension = true )
$file string

The file name.

$magicFile string

Name of the optional magic database file (or alias), usually something like /path/to/magic.mime. This will be passed as the second parameter to finfo_open() when the fileinfo extension is installed. If the MIME type is being determined based via getMimeTypeByExtension() and this is null, it will use the file specified by $mimeMagicFile.

$checkExtension boolean

Whether to use the file extension to determine the MIME type in case finfo_open() cannot determine it.

return string

The MIME type (e.g. text/plain). Null is returned if the MIME type cannot be determined.

throws yii\base\InvalidConfigException

when the fileinfo PHP extension is not installed and $checkExtension is false.

doc_Yii
2016-10-30 17:04:44
Comments
Leave a Comment

Please login to continue.