SqlConnection con = new SqlConnection("Data Source=DEEPAK-PC\\SQLEXPRESS;Initial Catalog=Imageup;User ID=sa;Password=sasa"); protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { String str = FileUpload1.FileName; //FileUpload1.PostedFile.SaveAs(Server.MapPath(",") + "~//uploadedimages//" + str); string FileName= Path.GetFileName(FileUpload1.FileName); FileUpload1.SaveAs(Server.MapPath("~/uploadedimages/")+ FileName); string path = "~//Uploads//"+str.ToString(); con.Open(); SqlCommand cmd = new SqlCommand("insert into FileUploads1 values('" + TextBox1.Text + "','" + path + "')", con); cmd.ExecuteNonQuery(); con.Close(); Label1.Text = "Image upload Successfully"; } else { Label1.Text = "Plz select ur image and upload"; } SqlDataAdapter da = new SqlDataAdapter("select * from FileUploads1", con); DataTable dt = new DataTable(); da.Fill(dt); GridView1.DataSource = dt; DataBind(); }
FileUpload1.SaveAs(Server.MapPath("~/uploadedimages/")+ FileName);
"insert into FileUploads1 values('" + TextBox1.Text + "','" + path + "'
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)