PHP code example of mzur / guess-mime
1. Go to this page and download the library: Download mzur/guess-mime library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mzur / guess-mime example snippets
use Mzur\GuessMIME\GuessMIME;
$gm = new GuessMIME;
$mime = $gm->guess('image.jpg');
var_dump($mime); // image/jpeg
use Mzur\GuessMIME\GuessMIME;
// Limit detection to image/jpeg and use a different database file.
$gm = new GuessMIME(['image/jpeg'], '/home/user/.mime.types');
// Default MIME type.
$mime = $gm->guess('image.png');
var_dump($mime); // application/octet-stream
// Use strict check.
$mime = $gm->guess('image.png', true);
var_dump($mime); // null