Overview

Packages

  • Mime

Classes

  • Horde_Mime
  • Horde_Mime_Address
  • Horde_Mime_Exception
  • Horde_Mime_Headers
  • Horde_Mime_Magic
  • Horde_Mime_Mail
  • Horde_Mime_Mdn
  • Horde_Mime_Part
  • Horde_Mime_Translation
  • Overview
  • Package
  • Class
  • Tree

Class Horde_Mime_Magic

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

Copyright 1999-2012 Horde LLC (http://www.horde.org/)

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Package: Mime
Category: Horde
License: LGPL 2.1
Author: Anil Madhavapeddy anil@recoil.org
Author: Michael Slusarz slusarz@horde.org
Located at Horde/Mime/Magic.php
Methods summary
public static string
# extToMime( string $ext )

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

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.

Parameters

$ext
The file extension to be mapped to a MIME type.

Returns

string
The MIME type of the file extension.
public static string
# filenameToMime( string $filename, boolean $unknown = true )

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

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

Parameters

$filename
The filename to be mapped to a MIME type.
$unknown
<p>How should unknown extensions be handled? If true, will return 'x-extension/*' types. If false, will return 'application/octet-stream'.</p>

Returns

string
The MIME type of the filename.
public static string
# mimeToExt( string $type )

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

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.

Parameters

$type
The MIME type to be mapped to a file extension.

Returns

string
The file extension of the MIME type.
public static mixed
# analyzeFile( string $path, string $magic_db = null, array $opts = array() )

Attempt to determine the MIME type of an unknown file.

Attempt to determine the MIME type of an unknown file.

Parameters

$path
The path to the file to analyze.
$magic_db
Path to the mime magic database.
$opts
Additional options: <pre><span class="php-quote">'nostrip'</span> - (boolean) Don<span class="php-quote">'t strip parameter information from MIME type string. DEFAULT: false</span></pre>

Returns

mixed

The MIME type of the file. Returns false if the file type can not be determined.

public static mixed
# analyzeData( string $data, string $magic_db = null, array $opts = array() )

Attempt to determine the MIME type of an unknown byte stream.

Attempt to determine the MIME type of an unknown byte stream.

Parameters

$data
The file data to analyze.
$magic_db
Path to the mime magic database.
$opts
Additional options: <pre><span class="php-quote">'nostrip'</span> - (boolean) Don<span class="php-quote">'t strip parameter information from MIME type string. DEFAULT: false</span></pre>

Returns

mixed

The MIME type of the file. Returns false if the file type can not be determined.

API documentation generated by ApiGen