RE: [PHP] checking image extensions

From: Date: Sun, 18 Feb 2001 15:34:34 +0000
Subject: RE: [PHP] checking image extensions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-40423@lists.php.net to get a copy of this message
or, a bit more concisely, you could use a regexp... to allow only jpg/gif/png file formats, setup the regexp to match on those three formats, and yell at people who submit anything other than those three.... $imgName = "one.jpg"; if (! preg_match('/\.(jpg|gif|png)$/', $imgName) ) { print "file format is not supported!"; } > -----Original Message----- > From: John Vanderbeck [mailto:agathorn@cfl.rr.com] > Sent: Saturday, February 17, 2001 08:27 > To: Alvin Tan; Php-General > Subject: Re: [PHP] checking image extensions > > > > Hi, Newbie question here. I'm trying to write a function to check an image > > extension, part of the code is: > > > > if (substr($imgName, -4) != ".jpg") > > if ((substr($imgName, -4) != ".jpg") || (substr($imgName, -4) != ".gif")) > { > echo "<P CLASS=Error>I'm sorry, but the ikmage format you submitted is not > a supported format.</P>"; > } > > - John Vanderbeck > - Admin, GameDesign > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#40423) next »