PHP Classes

PHP File Info: Get several types of information about files

Recommend this page to a friend!
  Info   View files Documentation   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2014-10-24 (1 year ago) RSS 2.0 feedNot yet rated by the usersTotal: 332 All time: 6,704 This week: 974Up
Version License PHP version Categories
file-info 0.1.2GNU General Publi...5.3PHP 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.

Picture of Nathan Bishop
  Performance   Level  
Name: Nathan Bishop <contact>
Classes: 2 packages by
Country: Australia Australia
Age: ???
All time rank: 301635 in Australia Australia
Week rank: 1373 Up13 in Australia Australia Up



Build Status

Table of Contents

<a name="about"></a>About

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.

    __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

<a name="license"></a>License

(GNU General Public License, version 2)

Copyright &copy; 2013, Nathan Bishop

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 <>.

  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Files folder imagetests (1 file)
Accessible without login Plain text file Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file FileInfo.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Accessible without login Plain text file FileInfoTest.php Test Unit test script

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:6,704
This week:974Up