note 82757 added to function.finfo-file

From: Date: Thu, 24 Apr 2008 16:53:46 +0000
Subject: note 82757 added to function.finfo-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-138742@lists.php.net to get a copy of this message
Another interresting feature of finfo_file on Windows. This function can return empty string instead of FALSE for some file types (ppt for example). Therefore to be sure do a triple check of output result and provide default type just in case. Here is a sample code: $ftype = 'application/octet-stream'; $finfo = @finfo_open(FILEINFO_MIME); if ($finfo !== FALSE) { $fres = @finfo_file($finfo, $file); if ( ($fres !== FALSE) && is_string($fres) && (strlen($fres)>0)) { $ftype = $fres; } @finfo_close($finfo); } ---- Server IP: 190.2.55.3 Probable Submitter: 200.49.157.165 ---- Manual Page -- http://www.php.net/manual/en/function.finfo-file.php Edit -- https://master.php.net/note/edit/82757 Del: integrated -- https://master.php.net/note/delete/82757/integrated Del: useless -- https://master.php.net/note/delete/82757/useless Del: bad code -- https://master.php.net/note/delete/82757/bad+code Del: spam -- https://master.php.net/note/delete/82757/spam Del: non-english -- https://master.php.net/note/delete/82757/non-english Del: in docs -- https://master.php.net/note/delete/82757/in+docs Del: other reasons-- https://master.php.net/note/delete/82757 Reject -- https://master.php.net/note/reject/82757 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#138742) next »