2013-10-14 59 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

做它不能意味着根本沒有這種可能性 –

相關問題