When handling file uploads, it is often important to determine the type of file being uploaded. While some files may be easily recognizable based on their contents, others may prove to be hard to identify.
MagicDb is a file database that consists of specifications for several file formats. This recipe shows us how to use this database, through CakePHP's
MagicDb class, to properly identify files uploaded by our users.
The license for the
MagicDb database file allows its use only on open source or freely available software. If you wish to identify files on commercial applications, you will have to find a different approach.
As we will be working on files uploaded by our users, we need to build a form ...