Great points, and I figured as much would be needed to 'rule in' acceptable items


do you think that the browser mime type would be sufficient to 'rule out' items as a preliminary check?
ie: if it passes the mime test, do a size test, else don't bother


or, would that probably toss too many good pictures?



On Mar 2, 2005, at 5:04 PM, Dan Wilga wrote:

At 1:44 PM -0500 3/1/05, Jonathan Vanasco wrote:
I'm in need of a 'good' method to limit files uploaded via mod_perl2 ( to photos of gif/jpg/png 100k or less)

2 - i've noticed a type of "image/jpeg" "image/gif" "image/png" for uploaded file types. can this be relied on to any extent?

I wouldn't. You're relying on the browser to supply a proper MIMe type, which IMHO is not the best place to put the burden.


Personally, I use Image::Size::imgsize() (see CPAN) for this. It automagically figures out the image's type (and size) based upon the file header. It doesn't even rely upon the .jpg or .gif ending, which would also be a bad idea.

--
Dan Wilga                                         [EMAIL PROTECTED]
Web Administrator                             http://www.mtholyoke.edu
Mount Holyoke College                                Tel: 413-538-3027
South Hadley, MA  01075            "Who left the cake out in the rain?"



Reply via email to