Skip to content
This repository has been archived by the owner on Sep 17, 2020. It is now read-only.

Latest commit

 

History

History
27 lines (18 loc) · 1.32 KB

README.md

File metadata and controls

27 lines (18 loc) · 1.32 KB

ancarda/file-detector

MIME type detector for partial file streams of unlimited length

Latest Stable Version Total Downloads License Build Status Coverage Status

file-detector is a library for PHP 7.0+ that accepts a file stream of any length, even if it's a partial file type, and provides a MIME detector for it.

The detector class can be used with any framework and has no dependencies. This library may be installed via composer with the following command:

composer require ancarda/file-detector

The detector can then be initalized and used, like so. For example:

<?php

$resource = fopen('example.jpg', 'r');
$detector = new \Ancarda\File\Detector;
$mimetype = $detector->determineMimeType($resource);

//$mimetype is now 'image/jpg'