getMagicFile(); $type = null; if (class_exists('finfo', false)) { $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; if (!empty($mimeFile)) { $mime = new finfo($const, $mimeFile); } else { $mime = new finfo($const); } if ($mime !== false) { $type = $mime->file($file); } unset($mime); } if (empty($type) && (function_exists('mime_content_type') && ini_get('mime_magic.magicfile'))) { $type = mime_content_type($file); } if (null !== $type) { header('Content-Type: ' . $type); } header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; } }