# PHP File Info: Get several types of information about files

 Last Updated Ratings Unique User Downloads Download Rankings 2014-10-24 (1 year ago) Not yet rated by the users Total: 332 All time: 6,704 This week: 974
 Version License PHP version Categories file-info 0.1.2 GNU General Publi... 5.3 PHP 5, Files and Folders
Description Author

This class can get several types of information about files.

It takes a given file name and if it exists in can return several details about that file.

Currently it returns the file directory path, base name, file name extension, and the detected MIME type based on the file name extension.

 Performance Level
Name: Classes: Nathan Bishop  2 packages by Nathan Bishop Australia ??? 3016 35 in Australia 1373 13 in Australia

Details

# FileInfo

FileInfo is simply a class that mimics the functionality of: - path_info() - file_info | finfo

## <a name="getting-started"></a>Getting Started

1. PHP 5.3.x is required
2. Install manually

## <a name="usage"></a>Usage

Include and instantiate:

require 'path\to\FileInfo.php';

$finfo = new FileInfo('path\to\file.txt', true);  Get mimetype using a function: $finfo->getMimeType(); // returns 'text/plain'


Or get mimetype as a class property:

$finfo->mimetype; // returns 'text/plain'  ## <a name="api"></a>API Below is a list of the public methods available for use. $finfo->
__construct($file,$exists = false)     // Set file and check for file existence.
getDirectory()                          // Get the directory.
getBaseName()                           // Get the basename (with extension).
getExtension()                          // Get the file extension.
getFileName()                           // Get the filename (basename without extension).
getMimeType()                           // Get the mimetype/content-type.
__isset($key) // Allows to check __get() properties for existence. __get($key)                             // Get a non-existant class property.


## <a name="testing"></a>Testing

This project keeps all tests stored in the /tests folder and uses the PHPUnit testing framework.

## <a name="contributors"></a>Contributors

(GNU General Public License, version 2)

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

 Files
File Role Description
src (1 file)
tests (1 file)

 Files / src
File Role Description
FileInfo.php Class Class source

 Files / tests
File Role Description
FileInfoTest.php Test Unit test script