Originally posted by johnie
Hi. I'm using
preg_match('/(gif|png|jpe?g)$/',$ext)
to check the extensions of the images and if it's ok then i upload.
All three extensions pass the checkpoint and appear that the script finishes what it's supposed to do without any errors.
However only .jpg images actually upload. The other 2 extensions don't do anything.
Is there something wrong with the preg_match()?
Thanks
John
The preg_match() looks fine, assuming the extensions are all always lower case (if not, add the 'i' modifier to the end of the regexp).
But why, if you say it's working, do you think it's the problem? I'd suspect the problem is elsewhere. Where else does the extension get mentioned?
If you want to be sure it's the preg_match and not something else, replace it with the equivalent
($ext=='gif' || $ext=='jpg' || $ext=='jpeg' ...etc. )
and see if you still get problems.