Eğer PHP (yani 5.3) son bir yeterince sürümünü kullanarak veya PECL uzantıları yüklemek için olanağına sahip iseniz, o PHP 5.3 ile birlikte oluyor, Fileinfo extension bir göz atmalısınız.
the given examples birini alıntı, bu gibi bir kod bölümü:
<?php
$finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
foreach (glob("*") as $filename) {
echo finfo_file($finfo, $filename) . "\n";
}
finfo_close($finfo);
?>
Sana böyle bir şey alabilirsiniz:
text/html
image/gif
application/vnd.ms-excel
If you're stuck with an older version of PHP, and cannot install PECL extensions, maybe the mime_content_type
function would do.