Re[2]: [PHP] Re: need help with uploading images

From: Date: Tue, 30 Jul 2002 08:47:00 +0000
Subject: Re[2]: [PHP] Re: need help with uploading images
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-110320@lists.php.net to get a copy of this message
Hi, Tuesday, July 30, 2002, 1:53:50 PM, you wrote: D> This looks good but I just have one question about it if you don't mind, D> what if someone was uploading a gif or a PNG file? can it be made to only D> detect jpgs? D> Thanks in advance D> Deadsam >> Try it this way, it will check if it is a jpeg and it has a horizontal >> and vertical size so you can be pretty sure it is an image file. >> (you do not need the gd package for getimagesize()) >> >> >> /** Check for the type of the image : only allow jpeg's */ >> $im = getimagesize($_FILES['uploadFile'); >> if(!($im[2] == 2 && $im[0] > 0 && $im[1] > 0)){ >> echo "You can only upload jpg images."; >> exit(); >> } The $im[2] being set to 2 means it is a jpeg other image types have a different number, have a look at the getimagesize()function for details -- regards, Tom

« previous php.general (#110320) next »