note 82756 deleted from function.finfo-file by felipe

From: Date: Sat, 26 Apr 2008 02:45:38 +0000
Subject: note 82756 deleted from function.finfo-file by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-138798@lists.php.net to get a copy of this message
Note Submitter: darko at uvcms dot com ---- Another interresting feature of finfo_open 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); }

« previous php.notes (#138798) next »