【发布时间】:2018-10-02 15:19:15
【问题描述】:
我将图像上传到 byte[] 格式的表格中。我的问题是,当我在视图上检索它时,图像不会显示出来。
型号
{
public byte[] image {get; set;}
}
控制器
public async Task<IActionResult> Create(Profile profile, IFormFile image)
{
if (ModelState.IsValid)
{
using (var memoryStream = new MemoryStream())
{
image.CopyTo(memoryStream);
profile.image = memoryStream.ToArray();
}
_context.Add(image);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(image);
}
查看
<img src="@item.image" />
【问题讨论】:
标签: asp.net-core-mvc-2.0 asp.net-core-mvc-2.1