GithubHelp home page GithubHelp logo

isabella232 / mime_type Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pear/mime_type

0.0 0.0 0.0 75 KB

Detect the MIME Type of a file

Home Page: http://pear.php.net/package/MIME_Type

PHP 100.00%

mime_type's Introduction

MIME_Type

PHP library to detect, parse and work with MIME types.

Features:

  • Parse MIME types
  • Supports full RFC 2045 specification
  • Many utility functions for working with and determining info about types
  • Most functions can be called statically
  • Autodetect a file's mime-type, either with fileinfo extension, mime_magic extension, the 'file' command or an in-built file extension mapping list

Installation

PEAR

$ pear install MIME_Type

Composer

$ composer require pear/mime_type

Usage

See the examples in the docs/examples/ directory and the official documentation.

Detecting a file's MIME type

<?php
require_once 'MIME/Type.php';
$type = MIME_Type::autoDetect('/path/to/file');
if (PEAR::isError($type)) {
    echo 'Error: ' . $type->getMessage() . "\n";
    exit(1);
} else {
    echo 'MIME type: ' . $type . "\n";
}
?>

Links

Homepage
http://pear.php.net/package/MIME_Type
Bug tracker
http://pear.php.net/bugs/search.php?cmd=display&package_name[]=MIME_Type
Documentation
http://pear.php.net/package/MIME_Type/docs
Unit test status

https://travis-ci.org/pear/MIME_Type

https://travis-ci.org/pear/MIME_Type.svg?branch=master

Development

Updating extension mapping

The built-in extension-to-type mapping list can be updated from apache's source code repository:

$ ./scripts/update-mimelist.php
...
785 new, 28 updated, 168 same, 5 own, 986 total
Code updated

The file MIME/Type/Extension.php will be changed now.

mime_type's People

Contributors

clockwerx avatar cweiske avatar loco8878 avatar till avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.