I want to save an image to a database. No problem when using a fileupload control. But I want to upload an image without using that control, just an image from a path on my hard drive. Seems like it should be a simple matter but I don't get it.
if (fu.PostedFile != null && fu.PostedFile.FileName != "")
{
byte[] imageSize = new byte[fu.PostedFile.ContentLength];
HttpPostedFile uploadedImage = fu.PostedFile;
uploadedImage.InputStream.Read(imageSize, 0, (int)fu.PostedFile.ContentLength);
SqlCommand cmd = new SqlCommand();
cmd = new SqlCommand();
cmd.CommandText = "UPDATE Images SET " + colName + "=(@Image) WHERE id=" + index;
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
SqlParameter UploadedImage = new SqlParameter("@Image", SqlDbType.Image, imageSize.Length);
UploadedImage.Value = imageSize;
cmd.Parameters.Add(UploadedImage);
conn.Open ...
Go to the complete details ...