PHP code example of softcreatr / php-mime-detector
1. Go to this page and download the library: Download softcreatr/php-mime-detector 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/ */
softcreatr / php-mime-detector example snippets
use SoftCreatR\MimeDetector\MimeDetector;
use SoftCreatR\MimeDetector\MimeDetectorException;
ctor('foo.bar');
// Get the MIME type and file extension
$fileData = [
'mime_type' => $mimeDetector->getMimeType(),
'file_extension' => $mimeDetector->getFileExtension(),
'file_hash' => $mimeDetector->getFileHash(),
];
// Print the result
echo '<pre>' . print_r($fileData, true) . '</pre>';
} catch (MimeDetectorException $e) {
die('An error occurred while trying to load the given file: ' . $e->getMessage());
}
bash
composer
bash
git clone https://github.com/SoftCreatR/php-mime-detector
cd php-mime-detector
git submodule update --init --recursive