On Apr 28, 2007, at 6:54 AM, tedd wrote:
At 2:10 AM +0200 4/28/07, Tim wrote:
On 21.04.2007 12:45, Alain Roger wrote:
Hi,
In my web application, end user is able to load images (png, jpeg,
gif,..) into database. I would like to know how can i detect
automatically the type of image (pnd, jpeg,...) ? i do not want to
check the extension because this is easily faked... just by renaming
it.
Does it exist a technique for that ?
thanks a lot,
Hi,
unfortunately mime_content_type() does not work for me.
Tim:
It should, but instead try this:
$image_size = getimagesize($filename);
echo $image_size['mime'];
$image_size['mime'] ? Where did that come from?
From the manual:
"Returns an array with 4 elements. Index 0 contains the width of the
image in pixels. Index 1 contains the height. Index 2 is a flag
indicating the type of the image: 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF,
5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte
order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15
= WBMP, 16 = XBM. These values correspond to the IMAGETYPE constants
that were added in PHP 4.3.0. Index 3 is a text string with the
correct height="yyy" width="xxx" string that can be used directly in
an IMG tag."
So it should be $image_size[2], or has something changed that I don't
know about?
Ed
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php