php - how to get mimetype of file in command line -


get mimetype finfo file

$finfo = new finfo(fileinfo_mime); $type = $finfo->file($file); 

get mimetype finfo string

$finfo = new finfo(fileinfo_mime); $type = $finfo->buffer($file); 

get mimetype in command line file

$type = shell_exec('file -bi '.escapeshellarg(realpath($file))); 

how mimetype in command line string?

as question tag says "php, linux", better try one.

$ mimetype <filename>  

example:

$ mimetype index.php index.php : application/x-php 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -