Colin dot Horne at Gmail dot com wrote:
> Also, you might consider using regular expressions:
>
> if (preg_match("^audio/mp[e]?g$", $_FILES['userfile']['type']))
A couple of points:
Remember delimiters. Just now you'll get a warning that
there is not an ending delimiter. '^', if uncommon, is fine
as a delimiter. I tend to use backticks, however, because
they seldom appear in the subjects of my patterns.
The character class is superfluous. The patterns
`^audio/mpe?g$` and `^audio/mp[e]?g$` are equivalent.
Your pattern allows for the strings 'audio/mpeg' and
'audio/mpg' but not 'audio/mp3'. Consider the slightly more
complicated `^audio/mp(?:3|e?g)$` (or `^audio/mp(?:e?g|3)$`
if you think the mpg and mpeg subtypes are more likely).
HAGS!
--
Jock<!-- ~MESSAGE_AFTER~ -->
>> Stay informed about: if and or question