note 88035 added to function.finfo-file

From: Date: Wed, 07 Jan 2009 05:29:01 +0000
Subject: note 88035 added to function.finfo-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-148911@lists.php.net to get a copy of this message
I thought to use fileinfo to check if a file was gzip or bzip2. However, the mime type of a compressed file is "data" because compression is an encoding rather than a type. gzip files begin with binary 1f8b. bzip2 files begin with magic bytes 'B' 'Z' 'h'. e.g. $s = file_get_contents("somefilepath"); if ( bin2hex(substr($s,0,2)) == '1f8b' ) { could be a gzip file } if( substr($s,0,3) == 'BZh' ){ could be a bzip2 file } I am not an encoding expert. My only testing was using a few of my own encoded files. ---- Server IP: 66.207.199.35 Probable Submitter: 66.18.249.3 ---- Manual Page -- http://www.php.net/manual/en/function.finfo-file.php Edit -- https://master.php.net/note/edit/88035 Del: integrated -- https://master.php.net/note/delete/88035/integrated Del: useless -- https://master.php.net/note/delete/88035/useless Del: bad code -- https://master.php.net/note/delete/88035/bad+code Del: spam -- https://master.php.net/note/delete/88035/spam Del: non-english -- https://master.php.net/note/delete/88035/non-english Del: in docs -- https://master.php.net/note/delete/88035/in+docs Del: other reasons-- https://master.php.net/note/delete/88035 Reject -- https://master.php.net/note/reject/88035 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#148911) next »