|
Posted by Lorenzo Thurman on 11/20/06 17:51
Pedro Graca wrote:
> 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';
> }
> ?>
>
Thanks for the reply, but do you know where I can get this info for
other types?
Navigation:
[Reply to this message]
|