• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/file.php
  • Класс: CFile
  • Вызов: CFile::GetContentType
static function GetContentType($path, $bPhysicalName = false)
{
	if($bPhysicalName)
	{
		$pathX = $path;
	}
	else
	{
		$io = CBXVirtualIo::GetInstance();
		$pathX = $io->GetPhysicalName($path);
	}

	$type = "";
	if (function_exists("mime_content_type"))
	{
		$type = mime_content_type($pathX);
	}

	if ($type == "" && function_exists("image_type_to_mime_type"))
	{
		$info = (new FileImage($pathX))->getInfo();
		if($info)
		{
			$type = $info->getMime();
		}
	}

	if ($type == "")
	{
		$type = WebMimeType::getByFileExtension(substr($pathX, bxstrrpos($pathX, ".") + 1));
	}

	return $type;
}