1 file.test FileFileTypeClassificationTestCase::getFileType($file)

Get the file type of a given file.

Parameters

$file: A file object.

Return value

The file's file type as a string.:

File

core/modules/file/tests/file.test, line 1826
Tests for file.module.

Class

FileFileTypeClassificationTestCase
Tests file type classification functionality.

Code

function getFileType($file) {
  $type = db_select('file_managed', 'fm')
    ->fields('fm', array('type'))
    ->condition('fid', $file->fid, '=')
    ->execute()
    ->fetchAssoc();

  return $type;
}