I’m using a php function finfo_file to determine mimetype and it keeps reporting .mpg files as application/octet-stream instead of video/mpeg.
I’m using CentOS, and in /etc/mime.types I see:
# grep 'mpg' /etc/mime.types
audio/mpeg mpga mp2 mp3
video/mpeg mpeg mpg mpe
Updated below is sample code:
$file = '/tmp/sample.mpg';
$fi = new finfo( FILEINFO_MIME_TYPE );
echo $fi->file( $file );
outputs:
application/octet-stream
These PHP functions depend on supplying a magic file which provides data to analyze a file’s content to determine its type. On a Unix system, this functionality is exposed via the
filecommand.At no time does it ever look at
/etc/mime.types.Since you didn’t specify a path to the magic file in your constructor, PHP uses
/usr/share/misc/magicby default. In CentOS, this file is provided by thefile-libspackage. If the package is missing or corrupt, you may get unexpected results.