REGEX Posix question
Posted: Fri May 02, 2008 10:33 am
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:
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.
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';
Can anybody advise me on how to properly secure that expression or make it more effecient.
thanks in advance.