Skip to content

Instantly share code, notes, and snippets.

@r37r0m0d3l
Last active October 10, 2015 14:47
Show Gist options
  • Save r37r0m0d3l/3706249 to your computer and use it in GitHub Desktop.
Save r37r0m0d3l/3706249 to your computer and use it in GitHub Desktop.
Get file mime type
<?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