一般我們都是按照文件擴展名來判斷文件類型
<?php
$files = array(
$fileTypes = array(
)
foreach($files as $file) {
$fp = fopen($file
$bin = fread($fp
fclose($fp)
$strInfo = @unpack(
$typeCode = intval($strInfo[
$fileType = isset($fileTypes[$typeCode]) ? $fileTypes[$typeCode] :
echo $file
}
From:http://tw.wingwit.com/Article/program/PHP/201311/20814.html