http://www.perlmonks.org?node_id=347066


in reply to Re: Getting File Type using Regular Expressions
in thread Getting File Type using Regular Expressions

Yes it is a CGI ap. What is the difference between $q->uploadInfo($file)->{'Content-Type'}; and using File::Type or File::MMagic? Do they check the same thing or what criteria do the base their assumptions on?

Replies are listed 'Best First'.
Re: Getting File Type using Regular Expressions
by Belgarion (Chaplain) on Apr 21, 2004 at 18:00 UTC

    The code:

    $type = $query->uploadInfo($filename)->{'Content-Type'};
    returns the Content-Type header the browser added to the upload. Basically, it's what the browser (or the user's computer) thinks this file is. It's not fool-proof however, and browsers are not required to include it.

    See the CGI documentation for more information.