You are here: Re: Validate an image type using php « PHP Programming Language « IT news, forums, messages
Re: Validate an image type using php

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация