PHP code example of 123dok / file-type-detector

1. Go to this page and download the library: Download 123dok/file-type-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/ */

    

123dok / file-type-detector example snippets


$type = Dok123\FileTypeDetector\Detector::detectByFilename($filename);
// or
$type = Dok123\FileTypeDetector\Detector::detectByContent('file-without-extension');
// or
$type = Dok123\FileTypeDetector\Detector::detectByContent(fopen('http://somedomain/somepath', 'r'));

$mime = Dok123\FileTypeDetector\Detector::getMimeType($file);
// or
$mime = Dok123\FileTypeDetector\Detector::getMimeType(fopen('somefile', 'r'));