Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Copyright 1999-2017 Horde LLC (http://www.horde.org/) See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Copyright: 1999-2017 Horde LLC
License: http://www.horde.org/licenses/lgpl21 LGPL 2.1
File Size: 235 lines (7 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 lib/horde/framework/Horde/Mime/mime.mapping.php

Defines 1 class

Horde_Mime_Magic:: (6 methods):
  _getMimeExtensionMap()
  extToMime()
  filenameToMime()
  mimeToExt()
  analyzeFile()
  analyzeData()


Class: Horde_Mime_Magic  - X-Ref

Utilities to determine MIME content-types of unknown content.

_getMimeExtensionMap()   X-Ref
Returns a copy of the MIME extension map.

return: array  The MIME extension map.

extToMime($ext)   X-Ref
Attempt to convert a file extension to a MIME type, based
on the global Horde and application specific config files.

If we cannot map the file extension to a specific type, then
we fall back to a custom MIME handler 'x-extension/$ext', which
can be used as a normal MIME type internally throughout Horde.

param: string $ext  The file extension to be mapped to a MIME type.
return: string  The MIME type of the file extension.

filenameToMime($filename, $unknown = true)   X-Ref
Attempt to convert a filename to a MIME type, based on the global Horde
and application specific config files.

param: string $filename  The filename to be mapped to a MIME type.
param: boolean $unknown  How should unknown extensions be handled? If
return: string  The MIME type of the filename.

mimeToExt($type)   X-Ref
Attempt to convert a MIME type to a file extension, based
on the global Horde and application specific config files.

If we cannot map the type to a file extension, we return false.

param: string $type  The MIME type to be mapped to a file extension.
return: string  The file extension of the MIME type.

analyzeFile($path, $magic_db = null,$opts = array()   X-Ref
Attempt to determine the MIME type of an unknown file.

param: string $path      The path to the file to analyze.
param: string $magic_db  Path to the mime magic database.
param: array $opts       Additional options:
return: mixed  The MIME type of the file. Returns false if the file

analyzeData($data, $magic_db = null,$opts = array()   X-Ref
Attempt to determine the MIME type of an unknown byte stream.

param: string $data      The file data to analyze.
param: string $magic_db  Path to the mime magic database.
param: array $opts       Additional options:
return: mixed  The MIME type of the file. Returns false if the file