Login   Register  
PHP Classes
elePHPant
Icontem

finfo: Determine the type of files analyzing its contents

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2012-03-16 (2 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 331 All time: 6,420 This week: 1,493Up
Version License PHP version Categories  
finfo 1.0GNU General Public Lice...5PHP 5, Files and Folders
Description Author  

This class can determine the type of files analyzing its contents.

It provides an interface compatible with PHP finfo extension under systems that do not have that PHP extension available.

It takes the path of a file and uses the file command to analyze its contents when possible. Otherwise the class reads the file contents to guess the file type and character encoding.

Innovation Award  
PHP Programming Innovation award nominee
March 2012
Number 6


Prize: One downloadable e-book of choice by O'Reilly
finfo is an useful PHP extension that makes it possible to determine the type of data contained in files by examining its contents.

Unfortunately the finfo extension is not available in all PHP setups. This class provides a work around by emulating the functionality of the finfo extensionin pure PHP code.

Manuel Lemos
Picture of Uku-Kaarel Jo~esaar
Name: Uku-Kaarel Jo~esaar <contact>
Classes: 8 packages by
Country: Estonia Estonia
Age: 31
All time rank: 4271 in Estonia Estonia
Week rank: 231 Up1 in Estonia Estonia Equal
Innovation award
Innovation award
Nominee: 5x

  Files folder image Files  
File Role Description
Plain text file class.finfo.php Class methods to try guess file type
Accessible without login Plain text file example.multipleFiles.php Example Lists directory files and their mime types
Accessible without login Plain text file example.myMagicDef.php Example Shows how to add or replace magic pattern
Accessible without login Plain text file loader.finfo.php Aux. loads finfo class if needed
Accessible without login Plain text file readme.doc.txt Doc. About implementation specific features

 Version Control Unique User Downloads Download Rankings  
 0%Total:331All time:6,420
 This week:0This week:1,493Up