Posted by mantrid on 10/16/06 20:30
thanks that explains a lot.
if i wanted to make it case insensitive should I simply remove the /i ?
also I thought || was 'or', is this special only to preg_match?
also
why the /\. and not just \.
Ian
"peter" <submit@flexiwebhost.com> wrote in message
news:egv0dc$34o$1@emma.aioe.org...
>
> > Found this piece of code using preg_match to check file types during
> > upload
> > of files.
> > $allowed_file_types = "(jpg|jpeg|gif|bmp|png)";
> > preg_match("/\." . $allowed_file_types . "$/i",
> > $_FILES['uploadedfile']["name"])
> >
> > I understand the basic preg_match but am confused as to how the string
> > pattern part is working i.e.
> > "/\." . $allowed_file_types . "$/i"
>
> the regular expression equates to the following:-
>
> "/\.(jpg|jpeg|gif|bmp|png)$/i"
>
> basically it is saying that the string MUST contain a . (which has been
> escaped by the slash) plus jpg OR jpeg OR gif OR bmp OR png. AS you see
the
> | means OR when enclosed in brackets like it currently is. The $ states
that
> the match must be at the end of the string (or in this case the file name)
> and the /i staes that the match should be case insensitive.
>
>
>
[Back to original message]
|