|Last Updated|| ||Ratings|| ||Unique User Downloads|| ||Download Rankings|
|2018-02-17 (7 months ago) || 70%||Total: 300 This week: 2||All time: 7,182 This week: 221|
This class can identify files via MIME type and file signatures.
It can take the path of a given file and read the beginning of its contents to detect the type of file based on recognizing signatures of well known file types.
The class can also detect the associated MIME type using the PHP finfo extension.
Identify a file through MIME type and file signature detection.
Detect a file's type through MIME type information and file signature (header) bytes.
(File extensions are ignored.)
*nix systems have the
file command, which is a powerful file identifier, and callable from PHP's shell functions.
Nevertheless, this command is not always available.
The main uses of File Identifier are:
- For \nix servers where PHP shell functions are disabled inphp.ini* (
- PHP running on Windows, where no
file command natively exists
- When older versions of
file (e.g. v. 5.09) are installed on the \*nix server, and which do not recognise some files such as .gpg
- Where custom, old, or rare file types cannot be identified by the
$f = new FileIdentifier('mira.png');
$r = $f->getResult();
echo $r['mimeinfo'] . PHP_EOL . $r['fileinfo'];
The file signature data (classes/filesignatures.class.php) contain a limited range of common file type signatures in hexadecimal bytes. This data array can be easily extended with additional and custom file signatures.
File Identifier is released under the GPL v.3.
||Applications that use this package
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.