in reply to CGI.pm file upload freaking me out

Well I don't really have much else to submit to this problem because it was covered by everyother person in the Monestary but I have one suggestion. Why don't you use substring instead of pattern matching to limit it to jpeg. Here is an example that should work...
my $jpeg = 'jpg'; if (lc(substr($upload,length($upload) - 4,4)) eq $jpeg){ ...do crap }
Then after that, you could do a s/// or t/// to replace .jpeg to .jpg, or just tweak with that a little. Best of luck!

Wanna be perl hacker.
Dave AKA damian

Replies are listed 'Best First'.
Re: Re: CGI.pm file upload freaking me out
by ryddler (Monk) on Jan 07, 2001 at 09:01 UTC

    Take a second look at the regex he used.

    if ($file_name !~ /\.jpe?g$/)

    The way he's using it covers both .jpg as well as .jpeg extensions in case the user tries to upload with either extension. However Trimbach, you might consider adding a "?" after the "g" as well, because as rare as it really is, .jpe is also an acceptable extension used with jpegs.

    ryddler

      On the other hand, /\.jpe?g?$/ would also allow .jp, so this might be more suitable: if ($file_name !~ /\.jp(?:eg?|g)$/)