Function to guess the MIME-type of the string data (from php-gears lib):
public static function guessMime(string $string): ?string
{
return (new finfo(FILEINFO_MIME_TYPE))->buffer($string) ?? null;
}
Eventually, the MIME-type of base64 encoded string:
guessMime(base64_decode($data));
or PPT/DOCX file:
mime_content_type("/foo/bar.docx");