PHP Classes

deprecation and charset problem

Recommend this page to a friend!

      Directory and file info  >  All threads  >  deprecation and charset problem  >  (Un) Subscribe thread alerts  
Subject:deprecation and charset problem
Summary:mime_content_type deprecated and file -bi with charset
Messages:1
Author:Jonathan Garcia Lima
Date:2009-11-15 05:40:11
 

  1. deprecation and charset problem   Reply   Report abuse  
Picture of Jonathan Garcia Lima Jonathan Garcia Lima - 2009-11-15 05:40:11
file -bi sometimes returns the charset with mimetype like "audio/mpeg; charset: binary", so that ruins your mime validation

mime_content_type is deprecated and also brings up the error above in *nix systems, i guess

the fix:
keep the function get_mime_content_type in directory_info class, looking like this:

function get_mime_content_type( $pathtofile ) {
if( !directory_info::valid_pathtofile( $pathtofile ) )
return false;

$finfo = finfo_open(FILEINFO_MIME_TYPE);
$fileMime = finfo_file($finfo, $pathtofile);
finfo_close($finfo);

return $fileMime;
}

just a reminder, this requires: (PHP >= 5.3.0, PECL fileinfo >= 0.1.0)