Breaking News
Loading...
Wednesday 13 March 2013

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@\/  <(.'.)>

0 comments:

Post a Comment

Thanks for comment

 
Toggle Footer