如果该文件是文件系统中的一个文件,则可以这样做:
shell_exec("file -bi $file")
但是如果文件是字符串(尚未保存为文件),您如何做到这一点?
字符串/文件是从带有imap_fetchbody()
$body = imap_fetchbody($this->stream, $this->msgno, $section);
$finfo = new finfo(FILEINFO_MIME);
echo $finfo->buffer($body) . "'n";
$file = Init::$dynamic['data_path'].$this->msgno.'_'.$part->dparameters[0]->value;
imap_savebody($this->stream, $file, $this->msgno, $section);
echo $finfo->file($file) . "'n";
$finfo->buffer()
和$finfo->file()
返回text/plain; charset=us-ascii
,即使它的PDF, PNG等?
finfo_buffer