2013-10-14 29 views
0

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

<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); 

回答

1

<input type"file">您不能设置值,如果你想显示的图像 - 写单独的页面,这将获取从数据库中的数据,并以适当的HTTP头将它张贴在HTML它会像<img src="/image.aspx?id=???" />

+0

我想在代码behiend –

+0

做它不能意味着根本没有这种可能性 –

相关问题