Sai Prasad Anumolu

Sai Prasad Anumolu

  • NA
  • 196
  • 18.9k

I have doubt in File uploading Control 2012?

Mar 13 2014 8:45 AM
First I take File upload control in asp.net and 
 
I upload image and  
After Click  on Save button ..Data is saving in database + Clear the Data in webpage  ... Then - This is First Image 
After I upload new image - Data is  not Saving in Database ....This is Second image ....
 
Code is :
 
if (FileTextAddsUpload.HasFile)  ---Frist Time accepting true ..But Send time Saving the image ...It will displaying False
{
string FileName = Path.GetFileName(FileTextAddsUpload.PostedFile.FileName);
string exten = Path.GetExtension(FileName);
if (exten == ".png" || exten == ".PNG" || exten == ".jpg" || exten == ".JPG" || exten == ".jpeg" || exten == ".JPEG" || exten == ".gif" || exten == ".GIF")
{
FileTextAddsUpload.SaveAs(Server.MapPath("~/Images/" + FileName));
con.Open();
id++;
SqlCommand cmd = new SqlCommand("InsertTextAdd_SP", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@TextAddImagePath", "~/Images/" + FileName);
cmd.Parameters.AddWithValue("@MaxCharLength", txtEnterChar.Text);
cmd.Parameters.AddWithValue("@Price", id);
cmd.ExecuteNonQuery();
con.Close();
Imagetextadd.Visible = true;
FileTextAddsUpload.ID = null;
}
ClearControls();
}
 
 
 

Answers (2)