Re: Check that uploaded photo is a JPEG
- From: wizofaus@xxxxxxxxxxx
- Date: 7 Feb 2007 18:23:10 -0800
On Feb 8, 1:06 pm, "Chris Mahoney" <chrismaho...@xxxxxxxxx> wrote:
Hi
I'm setting up a site where users will be able to upload photos. I'd
like to be able to ensure that they're uploading JPEGs, and not
malicious code. I've tried checking the MIME type, but that doesn't
seem to be reliable; for example if you rename an .exe to .jpg and
upload using Firefox, it returns "image/jpeg" (IE 6 returns
"application/octet-stream").
I understand that there probably isn't a surefire solution to this,
but a little security is better than none. Any advice? I'm using VB
2005 but I can read C# if I need to :)
Thanks
Chris
I would think the obvious (if not necessarily most efficient) solution
is to use System.Drawing.Image.FromFile(...): you can then check the
RawFormat property, or trap for any exceptions for invalid files. I
don't believe FromFile() can cause malicious code to execute.
.
- Follow-Ups:
- Re: Check that uploaded photo is a JPEG
- From: Chris Mahoney
- Re: Check that uploaded photo is a JPEG
- References:
- Check that uploaded photo is a JPEG
- From: Chris Mahoney
- Check that uploaded photo is a JPEG
- Prev by Date: Re: downloading .xls files from the web
- Next by Date: Re: my ip changed and now asp.net is broken!!
- Previous by thread: Check that uploaded photo is a JPEG
- Next by thread: Re: Check that uploaded photo is a JPEG
- Index(es):
Relevant Pages
|