在我的 .aspx 中,
<div id="pictureBox">
<img width="150" height="150" runat="server" id="imageField" />
</div>
<br />
<input id="Upload" style="width: 200px; font-family: Myanmar3;" type="file" name="Upload"
runat="server" accept="image/*" >
<br />
<asp:Button ID="ImageButton1" runat="server" OnClick="upload_Click" CssClass="styleButton"
Text="Upload" />
在我的 .cs 中,
protected void upload_Click(object sender, EventArgs e)
{
if (Upload.Value !="")
{
System.IO.Stream fs = Upload.PostedFile.InputStream;
img_uploadStream = Upload.PostedFile.InputStream;
System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
Byte[] bytes = CreateThumbnail(br.ReadBytes((Int32)fs.Length),150);
string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
imageField.Src = String.Format("data:{0};base64,{1}", "image/jpeg", base64String);
}
}
图片已上传并在“imageField”中显示成功,但“upload_Click”事件发生后“Upload”输入的value字段为空。我想把这个值拿回来做另一个过程!