finfo
on files を使用して取得する代わりにcontent-type
、Linux でコマンドを実行できます。
if(PHP_OS == 'WINNT'){
$finfo = new finfo(FILEINFO_MIME);
$content_type = $finfo->file($file);
}
else{
$content_type = shell_exec("file -bi $file");
}
ファイルの を文字列として取得したい場合はcontent-type
、これを行うことができます
$finfo = new finfo(FILEINFO_MIME);
$content_type = $finfo->buffer($data);
content-type
しかし、Linuxコマンドラインでファイルの内容を文字列として取得する代替手段はありますか?