1

我想在下一页显示我上传到服务器的图像和节点。

这是我的代码:'

public ActionResult Review(HttpPostedFileBase uploadfile)
        {

            string note = Request.Form["note"];
            string deliverytime = Request.Form["time"];
            HttpPostedFileBase imagetest = Request.Files["uploadfile"];
            System.Drawing.Bitmap bmpPostedImage = new System.Drawing.Bitmap(imagetest.InputStream);
            string imagestring = imagetest.ContentType.ToString();
            ViewBag.Mime = "image/jpeg";
Stream stream = uploadfile.InputStream;
                byte[] image = new byte[uploadfile.ContentLength];
                stream.Read(image, 0, uploadfile.ContentLength);
 ViewBag.Message = Convert.ToBase64String(image, Base64FormattingOptions.InsertLineBreaks);
                 ViewData["note"] = "user note:"+note;
               return PartialView();
}

' 和 cshtml

@Html.Encode(ViewData["note"])<br />
<img src="data:@ViewBag.Mime;base64,@ViewBag.Message" />

图像无法在下一页显示。非常感谢你的帮助!

4

0 回答 0