using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Data; using System.IO; public partial class UploadProductash : System.Web.UI.Page { SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["RSIC"].ConnectionString); string path1; string dbfpath; protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null) { Response.Redirect("login.aspx"); } } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { //***** For Small Image *******// string str1 = TextBox4.Text; string[] dtSplit = str1.Split('-'); string storedate = dtSplit[1] + "-" + dtSplit[0] + "-" + dtSplit[2]; if ((Attach.PostedFile != null) & Attach.PostedFile.ContentLength > 0) { string fn = System.IO.Path.GetFileName(Attach.PostedFile.FileName); Attach.PostedFile.SaveAs(Server.MapPath("~/data/") + fn); path1 = Server.MapPath("~/data/") + fn; dbfpath = "data/" + fn; if (con.State != ConnectionState.Open) { con.Open(); } string ins = "insert into Circular values('" + TextBox1.Text + "','" + storedate + "','" + dbfpath + "','" + dtSplit[1] + "')"; SqlCommand cm = new SqlCommand(ins, con); cm.ExecuteReader(); TextBox1.Text=""; TextBox4.Text=""; Label3.Visible = false; Label1.Visible = true; Label1.Text = "Newsletter Uploaded Successfully"; } else { Label3.Visible = true; Label3.Text = "Please select a file to upload."; } } }