Click here to Skip to main content
15,904,926 members
Please Sign up or sign in to vote.
3.00/5 (3 votes)
See more:
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 :

C#
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();
}
Posted
Updated 13-Mar-14 10:40am
v2
Comments
Sergey Alexandrovich Kryukov 13-Mar-14 9:00am    
What is the question?
—SA
Sai Prasad anumolu 13-Mar-14 9:02am    
Send Image is not accepting in database ....This is Doubt and Question sir

1 solution

Hi,
I could not find where your method FileTextAddsUpload came from?
Here is a link how to use FileUpload in ASP.Net...

http://msdn.microsoft.com/en-us/library/ms227669(v=vs.85).aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900