Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Is there an easy way (with/without a common module) to check a file's mimetype? I want to be a little more secure than checking a files extension for my file uploader.

Replies are listed 'Best First'.
Re: check file type
by suaveant (Parson) on Aug 20, 2007 at 18:25 UTC
    File::Type (uses file magic)

                    - Ant
                    - Some of my best work - (1 2 3)

      You could read the first 3 bytes of the file and use a regex statement to determine type, MZ, PK, RAR etc.