|
Posted by Pedro Graca on 11/16/06 20:17
Lorenzo Thurman wrote:
> Does anyone know how to validate a particular image type using PHP? If I
> have a file and I want to ensure that it is a jpeg, how would go about
> it? A sort of is_jpeg or is_gif is what I'm seeking.
http://www.php.net/getimagesize
Not tested
<?php
$image_data = getimagesize('whatever') or die('Unable to check
image.');
if ($image_data[2] == 2) {
echo 'File is an image of type JPG.';
} else {
echo 'File is not an image or, if it\'s an image, it\'s not of type JPG';
}
?>
--
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
Navigation:
[Reply to this message]
|