PDA

View Full Version : How to check for image extension in URL?


Moonlight
02-27-2000, 07:00 PM
I would like to know in PHP how I could check if an user enter an image URL when prompted.

I mean, to finish with .gif, .jpg or .png.

If it isn't OK, to return an error (ie, return 1).

Thanks,

Moonlight

jbroder
02-28-2000, 06:00 PM
try eregi.

if (eregi("gif$|jpg$",$formfield)) {

[nbsp][nbsp]echo "file $formfield is an image file";
[nbsp][nbsp]// do something here...
}

www.php.net (http://www.php.net) has the documentation on this.