Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

Picture Upload in asp.net

I want to upload pictures only using the file upload control .
what wud be the C# code for that

thanks
0
ASPNET_8
Asked:
ASPNET_8
1 Solution
 
Kumaraswamy RCommented:
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
 
ASPNET_8Author Commented:
Was not that helpful
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now