Hi
I used this code to uploading image and insert it to database
string path = Server.MapPath(".") + "\\../Upload\\";
string[] validext = { ".jpg", ".gif", ".png", ".rar" };
string ext =
System.IO.Path.GetExtension(AsyncFileUpload1.PostedFile.FileName);
if (Array.IndexOf(validext, ext.ToLower()) < 0)
{
lblMessage.Text = "File format not recognised. Upload Image/";
return;
}
//4-Get File Name
string filename = System.IO.Path.GetFileName(AsyncFileUpload1.PostedFile.FileName);
//5-Get File Exist and if (true)Generate New Name
while (System.IO.File.Exists(path + "\\" + filename))
filename = "1" + filename;
//6-Save File to Server
AsyncFileUpload1.PostedFile.SaveAs(path + filename);
SqlCommand _cmd = new SqlCommand("Fileup1", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
_cn.Open();
_cmd.Parameters.AddWithValue("@image", AsyncFileUpload1.FileBytes);
_cmd.Parameters.AddWithValue("@Behcode", "6666");
_cmd.ExecuteNonQuery();
_cn.Close();
my problem is that it didn't insert image name in database it save some unknown Characters in database
so when i want bind my image from database it didn't show image .