0

How can I make sure that the supplied file - font(TrueType)? File path may be specified with custom extension(non .ttf).

I'm confused.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Roman Nazarkin
  • 2,209
  • 5
  • 23
  • 44

1 Answers1

2

Check this: finfo

For example:

$fileName = 'file.ext';
$mimeTypes = array('font/ttf','font/truetype');
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $fileName);
if(in_array($mime, $mimeTypes)){
    echo 'font file';
}
finfo_close($finfo);

You must check FILEINFO_MIME_TYPE.

mkjasinski
  • 3,115
  • 2
  • 22
  • 21