eregi(); problems...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jim
Forum Contributor
Posts: 238
Joined: Fri Apr 19, 2002 5:26 am
Location: Near Austin, Texas

eregi(); problems...

Post by Jim »

Code: Select all

//Image Validation
if(!eregi("їa-z0-9]+(ї_\\.-]їa-z0-9])"+"."+"їjpg]" $userfile)){
echo 'File is not a valid .gif or .jpg image!';
}
Surely I'm doing this wrong. I'm checking a file against this to make sure it has either a .jpg or .gif extension.

Anyone have any ideas on how to do this?

Thanks!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Try,

Code: Select all

<?php
if (!ereg('(.jpg|.gif)$', $userfile)) &#123;
    echo 'File is not a valid .gif or .jpg image!';
&#125;
?>
There's a quick guide to regular expressions in the user submitted notes for ereg().

Mac
Post Reply