Download the PHP package blobfolio/blob-mimes without Composer
On this page you can find all versions of the php package blobfolio/blob-mimes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download blobfolio/blob-mimes
More information about blobfolio/blob-mimes
Files in blobfolio/blob-mimes
Package blob-mimes
Short Description A comprehensive MIME and file extension tool for PHP.
License WTFPL
Homepage https://github.com/Blobfolio/blob-mimes
Informations about the package blob-mimes
blob-mimes
DEPRECATED: This project is no longer actively maintained. Please see Righteous MIMEs instead.
A comprehensive MIME and file extension tool for PHP. Finally!
Table of Contents
- Features
- Requirements
- Installation
- Reference
- check_ext_and_mime()
- finfo()
- get_extension()
- get_extensions()
- get_mime()
- get_mimes()
- License
Features
It should be simple, but MIME types and file extensions are wildly inconsistent. Attempting to derive and/or correct that information when, e.g. verifying a file upload, is a nightmare in any programming language.
blob-mimes is a PHP library with a comprehensive MIME/ext database and simple helpers to access that information in a variety of ways:
- Pull MIME information based on a file name or extension;
- Pull file extensions for a given MIME type;
- Pull MIME information from a local file and verify its extension matches the actual content;
The database is compiled from the following sources:
Requirements
blob-mimes requires PHP 7.0+ with the following modules:
- BCMath
- DOM
- Fileinfo
- Filter
- JSON
- MBString
- SimpleXML
UTF-8 is used for all string encoding. This could create conflicts on environments using something else.
The build script additionally requires cURL.
Installation
Install via Composer:
Reference
check_ext_and_mime()
Verify that a file extension and MIME type belong together. Because technology is always evolving and the MIME standard is always changing, this will consider some/thing
and some/x-thing
equivalent.
Arguments
- (string) File extension
- (string) MIME type
- (bool) (optional) Soft pass. If
TRUE
, the check will returnTRUE
if it lacks information about either the extension or MIME type.
Returns
Returns TRUE
or FALSE
.
Example
finfo()
Pull path and type information for a file, using its name and/or content. If it is determined that the file is incorrectly named, alternative names with the correct file extension(s) are suggested.
Arguments
- (string) Path
- (string) (optional) Nice name. If provided, the nice name will be treated as the filename. This can be useful if passing a temporary upload, for example. Default:
NULL
Returns
Returns all file information that can be derived according to the format below.
Example
get_extension()
Retrieve information about a file extension.
Arguments
- (string) File extension
Returns
Returns the information or FALSE
. Note: The first MIME entry will always be the official (or most conventional) media type.
get_extensions()
Retrieve information about all known file extensions.
Arguments
N/A
Returns
Returns a MIME database organized by extension.
get_mime()
Retrieve information about a MIME type.
Arguments
- (string) MIME type
Returns
Returns the information or FALSE
.
Example
get_mimes()
Retrieve information about all known MIME types.
Arguments
N/A
Returns
Returns a MIME database organized by type. Note: The first extension should be the most common for the type.
License
Copyright © 2018 Blobfolio, LLC <[email protected]>
This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <[email protected]>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
Donations
If you have found this work useful and would like to contribute financially, Bitcoin tips are always welcome! 1Af56Nxauv8M1ChyQxtBe1yvdp2jtaB1GF |
All versions of blob-mimes with dependencies
ext-filter Version *
ext-dom Version *
ext-mbstring Version *
ext-json Version *
ext-bcmath Version *
ext-hash Version *
blobfolio/blob-common Version *