Class MIME_Magic

Description

The MIME_Magic:: class provides an interface to determine a MIME type for various content, if it provided with different levels of information.

$Horde: framework/MIME/MIME/Magic.php,v 1.52.8.18 2009/01/06 15:23:20 jan Exp $

Copyright 1999-2009 The Horde Project (http://www.horde.org/)

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.

Located in /MIME/MIME/Magic.php (line 21)


	
			
Method Summary
 string analyzeData (string $data, [string $magic_db = null])
 string analyzeFile (string $path, [string $magic_db = null])
 string extToMIME (string $ext)
 string filenameToMIME (string $filename, [boolean $unknown = true])
 string MIMEToExt (string $type)
Methods
analyzeData (line 230)

Uses variants of the UNIX "file" command to attempt to determine the MIME type of an unknown byte stream.

  • return: The MIME type of the file. Returns false if the file type isn't recognized or an error happened.
string analyzeData (string $data, [string $magic_db = null])
  • string $data: The file data to analyze.
  • string $magic_db: Path to the mime magic database.
analyzeFile (line 168)

Uses variants of the UNIX "file" command to attempt to determine the MIME type of an unknown file.

  • return: The MIME type of the file. Returns false if the file type isn't recognized or an error happened.
string analyzeFile (string $path, [string $magic_db = null])
  • string $path: The path to the file to analyze.
  • string $magic_db: Path to the mime magic database.
extToMIME (line 71)

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.

  • return: The MIME type of the file extension.
string extToMIME (string $ext)
  • string $ext: The file extension to be mapped to a MIME type.
filenameToMIME (line 105)

Attempt to convert a filename to a MIME type, based on the global Horde and application specific config files.

  • return: The MIME type of the filename.
string filenameToMIME (string $filename, [boolean $unknown = true])
  • string $filename: The filename to be mapped to a MIME type.
  • boolean $unknown: How should unknown extensions be handled? If true, will return 'x-extension/*' types. If false, will return 'application/octet-stream'.
MIMEToExt (line 137)

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.

  • return: The file extension of the MIME type.
string MIMEToExt (string $type)
  • string $type: The MIME type to be mapped to a file extension.

Documentation generated on Sun, 30 Jan 2011 05:19:24 +0000 by phpDocumentor 1.4.3