Solved

Picture Upload in asp.net

Posted on 2011-09-08
3
261 Views
Last Modified: 2012-05-12
I want to upload pictures only using the file upload control .
what wud be the C# code for that

thanks
0
Comment
Question by:ASPNET_8
3 Comments
 
LVL 8

Accepted Solution

by:
vsudip earned 500 total points
ID: 36501641
0
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 36501693
try

System.Drawing.Image img = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream);

if (img.RawFormat.Guid == System.Drawing.Imaging.ImageFormat.Jpeg.Guid)
 {
  //Ur coding

}

// if you want to return the type of the image, try this:

    public static string MimeType(System.Drawing.Image imgPhoto)
    {
        foreach (ImageCodecInfo codec in ImageCodecInfo.GetImageDecoders())
        {
            if (codec.FormatID == imgPhoto.RawFormat.Guid)
                return codec.MimeType;
        }
        return "image/unknown";
    }
0
 

Author Closing Comment

by:ASPNET_8
ID: 36586076
Was not that helpful
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question