PHP Classes

Metyl PHP MIME Type Check: Check a file to detect its MIME type

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 70 All time: 10,256 This week: 488Up
Version License PHP version Categories
metyl 1.0.0Freeware7Files and Folders, Validation, PHP 7
Description 

Author

This class can check a file to detect its MIME type.

It can take the path of a file as a parameter to determine its type.

The class can check the file name extension and contents using the MIME Magic or FileInfo PHP extension to determine the file MIME type.

The class can return the result stored in class variables that tell if the file is of a correct MIME type or the file MIME type is the same that it was requested to check.

Picture of wim niemans
  Performance   Level  
Name: wim niemans <contact>
Classes: 6 packages by
Country: The Netherlands The Netherlands
Age: ???
All time rank: 345789 in The Netherlands The Netherlands
Week rank: 86 Up3 in The Netherlands The Netherlands Up
Innovation award
Innovation award
Nominee: 2x

Recommendations

Upload any type of files
Check all the files based on the content

PHP code to identify uploaded file format
I need a code to identify the file format of uploaded file

Example

<?php

include 'metyl.class.php';
function
testMe($f) {
   
$result = metyl::make($f);
    echo
'fileName ' . $f;
    if (
$result->isValid()) {
        echo
" found! \n";
    } else {
        echo
" not suitable! \n";
    }
   
print_r($result);
}
testMe('Europa');
testMe(__FILE__);
exit;

/** Output of this :
fileName Europa found!
metyl Object
(
    [name] => Europa
    [baseName] => Europa
    [extension] => jpeg
    [mime] => image/jpeg; charset=binary
    [mimeType] => image/jpeg
    [encoding] => binary
    [message] =>
    [mappings] => Array
        (
            [0] => jpeg
            [1] => jpg
            [2] => jpe
            [3] => jfif
        )

    [errorsFound:protected] =>
)
fileName /Users/bonn/Desktop/P3/phpClasses/metyl/demo.php not suitable!
metyl Object
(
    [name] => /Users/bonn/Desktop/P3/phpClasses/metyl/demo.php
    [baseName] => demo.php
    [extension] => php
    [mime] => text/x-php; charset=us-ascii
    [mimeType] => text/x-php
    [encoding] => us-ascii
    [message] => extension php not like ???
    [mappings] => Array
        (
            [0] => ???
        )

    [errorsFound:protected] => 1
)
 */


  Files folder image Files  
File Role Description
Accessible without login Plain text file demo.php Example a simple demo
Accessible without login Image file Europa Data Image file without extension
Plain text file metyl.class.php Class a static singleton

 Version Control Unique User Downloads Download Rankings  
 0%
Total:70
This week:0
All time:10,256
This week:488Up