public function getMimeType()
    {
        if ($this->isUploaded() && $this->mime_type === null) {
            $temp_file_name = $this->getTempFileName();
            if (file_exists($temp_file_name)) {
                if (extension_loaded('fileinfo')) {
                    // Use the fileinfo extension if available.
                    $finfo = $this->getFinfo();
                    $this->mime_type = explode(
                        ';',
                        $finfo->file($temp_file_name)
                    )[0];
                } elseif (function_exists('mime_content_type')) {
                    // Fall back to mime_content_type() if available.
                    $this->mime_type = mime_content_type($temp_file_name);
                }

                // No mime-detection functions, or mime-detection function
                // failed to detect the type. Default to
                // 'application/octet-stream'. Relying on HTTP headers could
                // be a security problem so we never fall back to that option.
                if ($this->mime_type == '') {
                    $this->mime_type = 'application/octet-stream';
                }
            } else {
                $this->mime_type = $this->file['type'];
            }
        }

        return $this->mime_type;
    }