Solved

Picture Upload in asp.net

Posted on 2011-09-08
3
264 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

688 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