Skip to content

File uploading code for c# asp.net visual studio 2010

sunita sharma

Asked Apr 20, 2012, 10:46 PM EDT1 answer
Share
LinkedInX
Want to add photo in employee web form and then edit that photo also.

kindly give me code for the same.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Senthilkumar
    0
    Hi,

    You can use the file upload control to upload into the web server folder.

    <asp:FileUpload ID="fileUpload1" runat="server" />

    In the server side, you need to save the images after select the appropriate image

    if (fileUpload1.HasFile)
    {
           fileUpload1.PostedFile.SaveAs(Server.MapPath() + "\\Images\\" + fileUpload1.PostedFile.FileName.ToString());
    }

    Then, you can store the image name in the database along with the other information.

    The uploaded image can be shown in the image control.



    0