Re: Re[2]: [PHP] Re: need help with uploading images
| From: | Deadsam | Date: | Tue, 30 Jul 2002 22:31:22 +0000 |
| Subject: | Re: Re[2]: [PHP] Re: need help with uploading images | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-110428@lists.php.net to get a copy of this message | ||
wow I like it :)
thanks alot Tom you've been a big help and showed me something I never knew
before also at the time
Thanks to all who help me with this , it's very much appreciated
Deadsam
"Tom Rogers" <trogers@kwikin.com> wrote in message
news:176145653769.20020730184700@kwikin.com...
> 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
>