Freelance PHP programmer India | Freelance web developer india | Web development India | web developer CV india | Compiling PHP and Apache 2 from source on Linux
Fileinfo Functions
PHP Manual

finfo_file

(PHP >= 5.3.0, PECL fileinfo >= 0.1.0)

finfo_fileReturn information about a file

Description

string finfo_file ( resource $finfo , string $file_name=NULL [, int $options=FILEINFO_NONE [, resource $context=NULL ]] )
finfo
string file ( string $file_name=NULL [, int $options=FILEINFO_NONE [, resource $context=NULL ]] )

This function is used to get information about a file.

Parameters

finfo

Fileinfo resource returned by finfo_open().

file_name

Name of a file to be checked.

options

One or disjunction of more Fileinfo constants.

context

For a description of contexts, refer to Stream Functions.

Return Values

Returns a textual description of the contents of the filename argument, or FALSE if an error occurred.

Examples

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);
?>

The above example will output something similar to:

text/html
image/gif
application/vnd.ms-excel

See Also


Fileinfo Functions
PHP Manual