note 90796 deleted from function.finfo-open by danbrown
| From: | danbrown@php.net | Date: | Sun, 10 May 2009 21:40:44 +0000 |
| Subject: | note 90796 deleted from function.finfo-open by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154424@lists.php.net to get a copy of this message | ||
Note Submitter: rond dot nunes at gmail dot com
----
I've modified the function created by <ian@createanet.co.uk>.
His function check the mime even if the file doesn't exist.
I just added a file_exists verification.
If file exists, it returns the mime type, else, returns false;
<?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;
}}
?>