Solved

Picture Upload in asp.net

Posted on 2011-09-08
3
260 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

861 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now