if (imgFileUpload.HasFile)
{
HttpFileCollection hfc = Request.Files;
if (hfc.Count > 0)
{
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
string ext = System.IO.Path.GetExtension(hpf.FileName);
if (ext == ".jpg" || ext == ".bmp" || ext == ".gif" || ext== ".pdf" || ext == ".doc" || ext == ".docx")
{
buffer = new byte[hpf.ContentLength];
float bytes = hpf.InputStream.Read(buffer, 0, (int)hpf.ContentLength);
float size = bytes / 1024;
string s = @"~\images\galleryTestImages\" +hpf.FileName;
hpf.SaveAs(Server.MapPath(s));
string s1="insert into RW_GallerysImage values("+Convert.ToInt32(Session["Sno"].ToString())+",'"+s.ToString()+"')";
SqlCommand cmd = new SqlCommand(s1,con);
//cmd.CommandType = CommandType.StoredProcedure;
//SqlParameter p1 = new SqlParameter("@pImagePath",SqlDbType.VarChar);
//p1.Value = s.ToString();
//cmd.Parameters.Add(p1);
//p1 = new SqlParameter("@pTitleService",SqlDbType.VarChar);
//p1.Value = txtTitle.Text;
//cmd.Parameters.Add(p1);
con.Open();
cmd.ExecuteNonQuery();
//cmd2.ExecuteNonQuery();
lblstatus.Text = "<script>" + Environment.NewLine +"alert('Advertisment Posted Successfully')</script>";
GetServiceName();
con.Close();
panel2.Visible = true;
panel1.Visible = false;
txtTitle.Text = "";
}
}
}
}
}
{
HttpFileCollection hfc = Request.Files;
if (hfc.Count > 0)
{
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
string ext = System.IO.Path.GetExtension(hpf.FileName);
if (ext == ".jpg" || ext == ".bmp" || ext == ".gif" || ext== ".pdf" || ext == ".doc" || ext == ".docx")
{
buffer = new byte[hpf.ContentLength];
float bytes = hpf.InputStream.Read(buffer, 0, (int)hpf.ContentLength);
float size = bytes / 1024;
string s = @"~\images\galleryTestImages\" +hpf.FileName;
hpf.SaveAs(Server.MapPath(s));
string s1="insert into RW_GallerysImage values("+Convert.ToInt32(Session["Sno"].ToString())+",'"+s.ToString()+"')";
SqlCommand cmd = new SqlCommand(s1,con);
//cmd.CommandType = CommandType.StoredProcedure;
//SqlParameter p1 = new SqlParameter("@pImagePath",SqlDbType.VarChar);
//p1.Value = s.ToString();
//cmd.Parameters.Add(p1);
//p1 = new SqlParameter("@pTitleService",SqlDbType.VarChar);
//p1.Value = txtTitle.Text;
//cmd.Parameters.Add(p1);
con.Open();
cmd.ExecuteNonQuery();
//cmd2.ExecuteNonQuery();
lblstatus.Text = "<script>" + Environment.NewLine +"alert('Advertisment Posted Successfully')</script>";
GetServiceName();
con.Close();
panel2.Visible = true;
panel1.Visible = false;
txtTitle.Text = "";
}
}
}
}
}
No comments:
Post a Comment