{
    "mode": "perldoc",
    "parameter": "File::Type",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/File%3A%3AType/json",
    "generated": "2026-06-14T00:48:42Z",
    "synopsis": "my $ft = File::Type->new();\n# read in data from file to $data, then\nmy $typefromdata = $ft->checktypecontents($data);\n# alternatively, check file from disk\nmy $typefromfile = $ft->checktypefilename($file);\n# convenient method for checking either a file or data\nmy $type1 = $ft->mimetype($file);\nmy $type2 = $ft->mimetype($data);",
    "sections": {
        "NAME": {
            "content": "File::Type - determine file type using magic\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "my $ft = File::Type->new();\n\n# read in data from file to $data, then\nmy $typefromdata = $ft->checktypecontents($data);\n\n# alternatively, check file from disk\nmy $typefromfile = $ft->checktypefilename($file);\n\n# convenient method for checking either a file or data\nmy $type1 = $ft->mimetype($file);\nmy $type2 = $ft->mimetype($data);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "File::Type uses magic numbers (typically at the start of a file) to determine the MIME type of\nthat file.\n\nFile::Type can use either a filename, or file contents, to determine the type of a file.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "new\nReturns a new File::Type object.\n\nmimetype($argument)\nTakes either data or a filename, determines what it is, and passes the argument through to the\nrelevant method below. If the argument is a directory, returns undef.\n\nchecktypefilename($filename)\nOpens $filename (if possible; if not, returns undef) and returns the MIME type of the file.\n\nchecktypecontents($data)\nMatches $data against the magic database criteria and returns the MIME type of the file.\n",
            "subsections": []
        },
        "TODO": {
            "content": "* Add additional magic match criteria\n",
            "subsections": []
        },
        "BUGS": {
            "content": "None known.\n\nNOTES\nSome magic definitions in the mime-magic file used in the creation of this module vary from\nthose in other apps (eg image/x-png not image/png).\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "File::MMagic and File::MimeInfo perform the same job, but have a number of problems that led to\nthe creation of this module.\n\nFile::MMagic inlines a copy of the magic database, and uses a DATA filehandle, which causes\nproblems when running under modperl.\n\nFile::MimeInfo uses an external magic file, and relies on file extensions rather than magic to\ndetermine the mime type.\n\nAs a result, File::Type uses a separate module and script to create the code at the core of this\nmodule, which means that there is no need to include a magic database at all, and that it is\nsafe to run under modperl.\n\nFile::Type::Builder, which generates the code at the heart of this module.\n",
            "subsections": []
        },
        "ACKNOWLEDGMENTS": {
            "content": "File::Type is built from a mime-magic file from cleancode.org. The original can be found at\n<http://cleancode.org/cgi-bin/viewcvs.cgi/email/mime-magic.mime?rev=1.1.1.1>.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Paul Mison <pmison@fotango.com>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright 2003-2004 Fotango Ltd.\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "Licensed under the same terms as Perl itself.\n",
            "subsections": []
        }
    },
    "summary": "File::Type - determine file type using magic",
    "flags": [],
    "examples": [],
    "see_also": []
}