Last active
October 10, 2015 14:47
-
-
Save r37r0m0d3l/3706249 to your computer and use it in GitHub Desktop.
Get file mime type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class mime_type | |
{ | |
static function url_mime_type($url) | |
{ | |
$finfo = new \finfo(FILEINFO_MIME_TYPE); | |
return $finfo->buffer(file_get_contents($url)); | |
}; | |
static function file_mime_type($file_name) | |
{ | |
$file_name = \finfo_file($finfo = \finfo_open(FILEINFO_MIME_TYPE), $file_name) ); | |
\finfo_close($finfo); | |
return $filename; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment