add a file upload control , and try this here is a sample i'm providing
System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["SampleConnectionString"].ConnectionString);
public void AddProfile(string id, ,byte[] pic)
{
con.Open();
SqlCommand cmdIns = new SqlCommand("INSERT INTO profile (id,img) VALUES (@id,@pic)", con);
cmdIns.Parameters.Add("@id", SqlDbType.VarChar).Value = id;
cmdIns.Parameters.Add("@pic", SqlDbType.Image).Value = pic;
cmdIns.ExecuteNonQuery();
con.Close();
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
int l=uploadPhoto.PostedFile.ContentLength;
byte[] pic= new byte[l];
uploadPhoto.PostedFile.InputStream.Read(pic,0,l);
string typ = uploadPhoto.PostedFile.ContentType;
if ((typ == "image/jpeg" || typ == "image/jpg" || typ == "image/gif" || typ == "image/png" || typ == "image/bmp") && (l < 51200))
{
AddProfile(UserID,pic)
lblMessage.Text = "Profile Added !!";
}
else
{
lblMessage.Text = "! Image size must be less than 50kb and type must be (.jpeg/.jpg/.png/.gif/.bmp)";
}
}