CFile::getMimeType PHP Method

getMimeType() public method

If $_mime_type property is set, returned value is read from that property. This method will attempt the following approaches in order: 1. finfo 2. mime_content_type 3. {@link getMimeTypeByExtension} This method works only for files.
public getMimeType ( ) : string | boolean
return string | boolean the MIME type on success, 'False' on fail.
    public function getMimeType()
    {
        if ($this->_mime_type) {
            return $this->_mime_type;
        }
        if ($this->getIsFile()) {
            if ($this->getReadable()) {
                if ($this->_is_uploaded) {
                    return $this->_mime_type = $this->_uploaded_inst->getType();
                }
                if (function_exists('finfo_open')) {
                    if (($info = @finfo_open(FILEINFO_MIME)) && ($result = finfo_file($info, $this->_realpath)) !== False) {
                        return $this->_mime_type = $result;
                    }
                }
                if (function_exists('mime_content_type') && ($result = @mime_content_type($this->_realpath)) !== False) {
                    return $this->_mime_type = $result;
                }
                return $this->_mime_type = $this->getMimeTypeByExtension($this->_realpath);
            }
            $this->addLog('Unable to get mime type for file');
            return False;
        } else {
            $this->addLog('getMimeType() method is available only for files', 'warning');
            return False;
        }
    }