note 90797 added to function.finfo-open
| From: | rond dot nunes at gmail dot com | Date: | Sun, 10 May 2009 16:11:01 +0000 |
| Subject: | note 90797 added to function.finfo-open | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-154414@lists.php.net to get a copy of this message | ||
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;
}}
?>
----
Server IP: 200.185.126.115
Probable Submitter: 189.12.134.183
----
Manual Page -- http://www.php.net/manual/en/function.finfo-open.php
Edit -- https://master.php.net/note/edit/90797
Del: integrated -- https://master.php.net/note/delete/90797/integrated
Del: useless -- https://master.php.net/note/delete/90797/useless
Del: bad code -- https://master.php.net/note/delete/90797/bad+code
Del: spam -- https://master.php.net/note/delete/90797/spam
Del: non-english -- https://master.php.net/note/delete/90797/non-english
Del: in docs -- https://master.php.net/note/delete/90797/in+docs
Del: other reasons-- https://master.php.net/note/delete/90797
Reject -- https://master.php.net/note/reject/90797
Search -- https://master.php.net/manage/user-notes.php