Page 1 of 1

REGEX Posix question

Posted: Fri May 02, 2008 10:33 am
by remyx187
Hi,

I am trying to code in a validator for an upload and i need to check for a text file extension (since word 2007 docs are read as in apps i will use the name of the file itself). I want specified text files to go through while throwing everything else out

This is my code so far:

Code: Select all

 
if(eregi("(^.*)([(\.doc\)(\.docx\)(\.txt\)(\.rtf\)])$", $_FILES['application_essay']['name']) == FALSE)
$notype = 'wrong_type';
 
I checked over many extensions and it seems to catch files effeciently except, what I caught, a .pdf extension that got through.

Can anybody advise me on how to properly secure that expression or make it more effecient.

thanks in advance.

Re: REGEX Posix question

Posted: Fri May 02, 2008 4:40 pm
by Mordred
Don't try, it's impossible.
viewtopic.php?f=1&t=82057