Hello there webmaster world, hope we all are keeping well and geared up for the festive season that is just round the corner.
I have a problem with REGEX with a form that I am using, wherein an image too is uploaded.
The field for the image upload is thumbs. What I want to achieve is if the file extension is not gif or jpg or png, then an error should be shown as below.
So here is my code.
$thumb_type = $_POST['thumbs']['type'];
if(!preg_match('/^.(gif|jpg|png)$/', $thumb_type)) {
echo 'Error! - Invalid file type detected';
}
What is happening is even when I try to upload a jpg file, it is giving me the error message, which indicates that something is wrong with my above code.
Could the experts on REGEX please review my coding and advise where I have gone wrong or what changes should I bring in the code to get this working.
Your assistance, as always, is highly appreciated.
Regards
Melwyn