note 90824 deleted from function.finfo-open by danbrown
| From: | danbrown@php.net | Date: | Mon, 11 May 2009 20:47:29 +0000 |
| Subject: | note 90824 deleted from function.finfo-open by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154478@lists.php.net to get a copy of this message | ||
Note Submitter: rond dot nunes at gmail dot com
----
I've adapted Ian's function adding "file_exists" to return false if the file
doesn't exist:
hope u enjoy =D
<?php
function get_mime_type($filepath)
{
if(file_exists($filepath))
{
ob_start();
system("file -i -b {$filepath}");
$output = ob_get_clean();
$output = explode("; ",$output);
if ( is_array($output) )
{
$output = $output[0];
}
return $output;
}
else
{
return false;
}
}
?>