Click here to Skip to main content
13,094,001 members (56,497 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Can any one tell me how to select an image from my computer and insert the same into a database table column.
Posted 7-Oct-12 20:46pm
Nandakishorerao 8-Oct-12 7:04am
do u want to store the image in database or want to save image in folder and path to the database...just mention it...rajendran..
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


<form id="form1" runat="server">
    <asp:FileUpload id="FileUploadControl" runat="server" />
    <asp:Button runat="server" id="UploadButton" text="Upload" onclick="UploadButton_Click" />
    <br /><br />
    <asp:Label runat="server" id="StatusLabel" text="Upload status: " />

Code behind
protected void UploadButton_Click(object sender, EventArgs e)
            if(FileUploadControl.PostedFile.ContentType == "image/jpeg")
                if(FileUploadControl.PostedFile.ContentLength < 102400)
                    string filename = Path.GetFileName(FileUploadControl.FileName);
                    FileUploadControl.SaveAs(Server.MapPath("~/") + filename);
                    StatusLabel.Text = "Upload status: File uploaded!";
                    StatusLabel.Text = "Upload status: The file has to be less than 100 kb!";
                StatusLabel.Text = "Upload status: Only JPEG files are accepted!";
        catch(Exception ex)
            StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100