add check img type by data

This commit is contained in:
october 2017-04-19 15:32:46 +08:00
parent 113a0f1d62
commit 01de45e729

View File

@ -3,10 +3,17 @@
*7173 gif *255216 jpg *13780 png *6677 bmp *239187 txt,aspx,asp,sql *208207 xls.doc.ppt *6063 xml *6033 htm,html *4742 js
*8075 xlsx,zip,pptx,mmap,zip *8297 rar *01 accdb,mdb *7790 exe,dll *5666 psd *255254 rdp *10056 bt种子 *64101 bat
*/
function getFileTypeByRaw( $data ){
$bin = $data[0].$data[1];
return getFileTypeBybin( $bin );
}
function getFileType( $file ){
$fp = fopen($file, "rb");
$bin = fread($fp, 2); //只读2字节
fclose($fp);
return getFileTypeBybin( $bin );
}
function getFileTypeBybin( $bin ){
$str_info = @unpack("C2chars", $bin);
$type_code = intval($str_info['chars1'].$str_info['chars2']);
$file_type = '';