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 -- h
ttps://master.php.net/note/delete/78051/integrated
Del: useless -- http
s://master.php.net/note/delete/78051/useless
Del: bad code -- htt
ps://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 -- http
s://master.php.net/note/delete/78051/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78051
Reject -- https://mast
er.php.net/note/reject/78051
Search -- https://
master.php.net/manage/user-notes.php
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|