The Image
control[
^] does not contain a
Save
method. But you don't need one - it's displaying an image from your server's disk.
string fileName = Server.MapPath(Image1.ImageUrl);
if (string.IsNullOrEmpty(fileName))
{
return;
}
byte[] data = File.ReadAllBytes(fileName);
using (MySqlConnection con = new MySqlConnection(myconstring))
using (MySqlCommand command = new MySqlCommand("INSERT INTO image (picture) VALUES (@IM)", con))
{
command.Parameters.AddWithValue("@IM", data);
con.Open();
command.ExecuteNonQuery();
}
NB: You'll want to validate that the uploaded file is actually an image. You'll also want to check that the filename provided by the user doesn't contain any characters which aren't valid in a Windows filename. Never trust user input! :)