note 78051 added to function.finfo-file

From: Date: Tue, 25 Sep 2007 21:01:49 +0000
Subject: note 78051 added to function.finfo-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-130786@lists.php.net to get a copy of this message
Just an improvement on the sample Ryan Day posted - slightly off topic since this method does not use finfo_file but in some cases this method might be preferable. The main change is the -format %m parameters given to the identify call. I would suggest using the full system path to identify i.e. /usr/bin/identify to be a little safer (the location may change from server to server though). <?php function is_jpg($fullpathtoimage){ if(file_exists($fullpathtoimage)){ exec("/usr/bin/identify -format %m $fullpathtoimage",$out); //using system() echos STDOUT automatically if(!empty($out)){ //identify returns an empty result to php //if the file is not an image if($out == 'JPEG'){ return true; } } } return false; } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 216.46.201.115 ---- Manual Page -- http://www.php.net/manual/en/function.finfo-file.php Edit -- https://master.php.net/note/edit/78051 Del: integrated -- https://master.php.net/note/delete/78051/integrated Del: useless -- https://master.php.net/note/delete/78051/useless Del: bad code -- https://master.php.net/note/delete/78051/bad+code Del: spam -- https://master.php.net/note/delete/78051/spam Del: non-english -- https://master.php.net/note/delete/78051/non-english Del: in docs -- https://master.php.net/note/delete/78051/in+docs Del: other reasons-- https://master.php.net/note/delete/78051 Reject -- https://master.php.net/note/reject/78051 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#130786) next »