Some files like PNG and GIF have a magic number in the file header. It is used to "identify the file" as a specific type like PNG. You just check the magic number and that tells you the type. But I don't understand why you would need this because it can be spoofed so easily and nobody is ever going to look at the file and read it I would suppose. It seems if you just assumed it was a specific mime-type and then it either worked or it didn't work, that would be just as effective.
Files in linux don't always have a .exe or .png extention at the end of them, like windows requires? So to mitigate that, the magic number is used to help id the file type and open it properly. This is originaly a unix thing that found it's way into linux because it's useful and habit, on the side of the coders.