O'Reilly logo

CakePHP 1.3 Application Development Cookbook by Mariano Iglesias

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Detecting file types with MagicDb

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.

Getting ready

As we will be working on files uploaded by our users, we need to build a form ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required