Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function autoDetect($file, $params = false)
- {
- // Sanity checks
- if (!file_exists($file)) {
- return PEAR::raiseError("File \"$file\" doesn't exist");
- }
- if (!is_readable($file)) {
- return PEAR::raiseError("File \"$file\" is not readable");
- }
- if (function_exists('finfo_file')) {
- $finfo = finfo_open(FILEINFO_MIME);
- $type = finfo_file($finfo, $file);
- finfo_close($finfo);
- if ($type !== false && $type !== '') {
- return MIME_Type::_handleDetection($type, $params);
- }
- }
- if (function_exists('mime_content_type')) {
- $type = mime_content_type($file);
- if ($type !== false && $type !== '') {
- return MIME_Type::_handleDetection($type, $params);
- }
- }
- @include_once 'System/Command.php';
- if (class_exists('System_Command')) {
- return MIME_Type::_handleDetection(
- MIME_Type::_fileAutoDetect($file),
- $params
- );
- }
- require_once 'MIME/Type/Extension.php';
- $mte = new MIME_Type_Extension();
- return $mte->getMIMEType($file);
- }
Add Comment
Please, Sign In to add comment