PHP code example of rosell-dk / image-mime-type-sniffer
1. Go to this page and download the library: Download rosell-dk/image-mime-type-sniffer 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/ */
rosell-dk / image-mime-type-sniffer example snippets
use \ImageMimeTypeSniffer\ImageMimeTypeSniffer;
$mimeType = ImageMimeTypeSniffer::detect($fileName);
if (is_null($mimeType)) {
// mimetype was not detected, which means the file is probably not an image (unless it is a rare type)
} else {
// It is an image, and we know the mimeType
}