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);
}
}
上传图片后,Upload.PostedFile.InputStream 已设置为空值。我想将此输入流保存到 asp.net 视图状态以重用。