static function Helper::get_mime_type in Anti Spam by CleanTalk 8.4
Same name and namespace in other branches
- 9.1.x src/lib/Cleantalk/Common/Helper.php \Cleantalk\Common\Helper::get_mime_type()
* Get mime type from file or data * *
Parameters
string $data Path to file or data: * @param string $type Default mime type. Returns if we failed to detect type * * @return string
1 call to Helper::get_mime_type()
- FirewallUpdater::unpackData in src/
lib/ Cleantalk/ Common/ Firewall/ FirewallUpdater.php
File
- src/
lib/ Cleantalk/ Common/ Helper.php, line 1139
Class
- Helper
- CleanTalk Helper class. Compatible with any CMS.
Namespace
Cleantalk\CommonCode
static function get_mime_type($data, $type = '') {
$data = str_replace(chr(0), '', $data);
// Clean input of null bytes
if (!empty($data) && @file_exists($data)) {
$type = mime_content_type($data);
}
elseif (function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$type = finfo_buffer($finfo, $data);
finfo_close($finfo);
}
return $type;
}