0

我想在文件类型的输入控件中显示图像。首先我从数据库中读取 var 二进制数据,然后将其转换为内存流,但我无法将变量传递给<input type="file" />. 我该怎么做?

<input type="file" name="images" id="images" runat=server />

SqlConnection con = new SqlConnection(stcon);
SqlCommand command = new SqlCommand();
command.CommandText = "select * from image where ImageId=4";
command.Connection = con;
SqlDataAdapter adapt = new SqlDataAdapter(command);
DataTable dt = new DataTable();
adapt.Fill(dt);
MemoryStream memStream = new MemoryStream((byte[])dt.Rows[0][1]);
Stream str;
memStream.CopyTo(str);
4

1 回答 1

1

如果要显示图像,则不能为 设置值<input type"file">- 编写单独的页面,该页面将从数据库中获取数据,并使用适当的 HTTP 标头发布,在 HTML 中就像<img src="/image.aspx?id=???" />

于 2013-10-14T10:46:07.763 回答