PHP Classes
elePHPant
Icontem

finfo: Determine the type of files analyzing its contents

Recommend this page to a friend!
  Info   View files Example   View files View files (17)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-01-10 (1 month ago) RSS 2.0 feedNot yet rated by the usersTotal: 344 All time: 6,706 This week: 805Up
Version License PHP version Categories
finfo 1.0GNU General Publi...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
Name: Uku-Kaarel Jo~esaar <contact>
Classes: 8 packages by
Country: Estonia Estonia
Age: 34
All time rank: 4031 in Estonia Estonia
Week rank: 302 Up3 in Estonia Estonia Down
Innovation award
Innovation award
Nominee: 5x

Details
class.finfo.php
---------------


 public $no_magic    <-- built in magic 
 public $flags       <-- finfo flags
 public $magic_file  <-- path to magic file
 
    Extra methods are not implmented in php's own 'finfo'
    .....................................................

    Set or overwrite/override magic file description
    set_magicDescription($key, $array);
 
    mime_class/sub_type
    get_mime_class()
    get_mime_subtype();
    
    Returns true if mime class is "text", also returns true on XML, CSS, JS, RTF, PHP.
    isTextualData();
 
 
 
 ----------------------------------------------------------------
 About me: http://ukj.pri.ee ukj@ukj.pri.ee
  Files folder image Files  
File Role Description
Files folder imagedir (11 files)
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 Aux. 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
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  dir  
File Role Description
  Accessible without login Image file A4_to_A5.png Data Auxiliary data
  Accessible without login Plain text file birds.rtf Data Auxiliary data
  Accessible without login Image file favicon.ico Data Auxiliary data
  Accessible without login Plain text file google_browser_detection.js Data Auxiliary data
  Accessible without login Plain text file HEADER Data Auxiliary data
  Accessible without login HTML file index.html Doc. Documentation
  Accessible without login Plain text file jquery.qtip.min.css Data Auxiliary data
  Accessible without login Image file sunset.jpg Icon Icon image
  Accessible without login Plain text file test.csv Data Auxiliary data
  Accessible without login Image file tree_expand.gif Icon Icon image
  Accessible without login Plain text file webgps.c.txt Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 94%
Total:344
This week:0
All time:6,706
This week:805Up