Re: Checking if an image

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Bob Powell [MVP] (bob_at__spamkiller_bobpowell.net)
Date: 04/19/04


Date: Tue, 20 Apr 2004 00:19:58 +0200

There is no such check that I know of.

You could attempy to open the image within a try-catch block. A bogus image
will almost certainly throw an exception that you can deal with
appropriately.

-- 
Bob Powell [MVP]
Visual C#, System.Drawing
All you ever wanted to know about ListView custom drawing is in Well Formed.
http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm
Read my Blog at http://bobpowelldotnet.blogspot.com
"Steve Peterson" <speterson@arrakis.es> wrote in message
news:%23cNh71kJEHA.2244@tk2msftngp13.phx.gbl...
> Hi
>
> I have an ASP.NET where users can upload images to the server. I've
already
> implemented business logic that checks the file extension of the files
> uploaded to make sure they are of an acceptable image type. However, it
> occured to me that a devious user might simply give some non image (Like
an
> .exe) file to an image extension, upload it,  and then cause havoc latter
> on.
>
> So, what I need to do is implement business logic that makes sure they
file
> uploaded IS an image file before saving to the server. I'm not familiar
with
> working with graphics, but I figure there must be some method in .NET that
> returns a boolean value if the file is an image format or something along
> those lines..
>
> Can anyone help me out??
>
> TIA
>
> Steve
>
>


Relevant Pages

  • Re: Password protection question.
    ... It looks like .htaccess is a file extension. ... It is not a file extension in the normal way. ... And then I change the name on the server itself by means of my FTP ... What would I upload to the server to check it. ...
    (alt.html)
  • Checking if an image
    ... I have an ASP.NET where users can upload images to the server. ... implemented business logic that checks the file extension of the files ... working with graphics, but I figure there must be some method in .NET that ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Check what kind of file extension is uploaded
    ... I am wondering how to controll what kind of file type the user can upload to the server. ... I like to find a solution where I can check the file type and only permit jpg files to be uploaded. ... Checking the file extension is problematic at best. ...
    (alt.php)
  • Re: File Upload - Security Issues
    ... You want to upload a file for what reason and ... these viruses have less chance of being able to execute (even if succeeded ... :> file and what pitfalls you see re: security might be helpful on this ... :>: files to an IIS server that doesn't have MS Office actually installed? ...
    (microsoft.public.scripting.vbscript)
  • Re: File Upload - Security Issues
    ... uploaded and the user could upload any or all of these in theory. ... There is no one product that can give you 100% security, ... > Code doesn't execute in local memory space unless remote user has rights ... > You don't have MS Office installed on the server. ...
    (microsoft.public.scripting.vbscript)