How to upload and save image in asp.net ?

For uploading the image file in asp.net website write following code.


//////////////////////////////   CODE     ////////////////////////////////

protected void Button1_Click(object sender, EventArgs e)
    {

        if (FileUpload1.HasFile)
        {
           
                string path = Server.MapPath(FileUpload1.PostedFile.FileName);
                FileUpload1.SaveAs(path);
                Image1.ImageUrl = FileUpload1.PostedFile.FileName;




            /*****************************************************
            // if you want to store it in any specific folder the

            *****************************************************/



             //string path = Server.MapPath("Photo/") + FileUpload1.PostedFile.FileName;
            //FileUpload1.SaveAs(path);
            //Image1.ImageUrl = "~/Photo/" + FileUpload1.PostedFile.FileName;

        }

////////////////////////////////////////////////////////////////

Download Code : UpaloadImage.rar

***************************************************************
See Also :
  Follow Me On Facebok

--
/\/ir@\/  <(.'.)>

Comments

Popular posts from this blog

How to get column value from the selected row in data grid in wpf c#.net

How to make and use web service in Microsoft Dynamics Navision.

How to use Format function in Microsoft Dynamics Navision.