(PECL fileinfo:0.1-1.0.4)
finfo_file — Return information about a file
This function is used to get information about a file.
Fileinfo resource returned by finfo_open().
Name of a file to be checked.
One or disjunction of more Fileinfo constants.
For a description of contexts, refer to Secuencias.
Returns a textual description of the contents of the filename argument, or FALSE if an error occurred.
Example#1 A finfo_file() example
<?php
$finfo = finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension
foreach (glob("*") as $filename) {
echo finfo_file($finfo, $filename) . "\n";
}
finfo_close($finfo);
?>
El resultado del ejemplo seria algo similar a:
text/html image/gif application/vnd.ms-excel