File::type()
\nn\t3::File()->type($filename = NULL);
Returns the type of file based on the file suffix
\nn\t3::File()->type('image.jpg'); => returns 'image'
\nn\t3::File()->type('text.doc'); => returns 'document'
Copied!
| @return string
Source Code
public function type($filename = null)
{
if (!$filename) return false;
$suffix = $this->suffix($filename);
foreach (self::$TYPES as $k => $arr) {
if (in_array($suffix, $arr)) return $k;
}
return 'other';
}
Copied!