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

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

 
Toggle Footer