I save pictures asbyte[]in the database. Im familiar with theHttpPostedFileBase in asp.net but they got rid of that in .net Core 5 apparently How can I send the uploaded picture
to the controller which converts it into picture and inserts into the database?
[HttpPost]
public IActionResult Index(UploadModel model)
{
// Here you can read the posted file stream from the request or copy it... var stream = model.UploadedPic.OpenReadStream();
return View();
}
Please mark as Answer if this post helps in resolving your problem
None
0 Points
2 Posts
How to post pictures to controller
Feb 12, 2021 03:56 AM|aaarianme|LINK
I save pictures as
byte[]
in the database. Im familiar with theHttpPostedFileBase
in asp.net but they got rid of that in .net Core 5 apparently How can I send the uploaded picture to the controller which converts it into picture and inserts into the database?C# controller
Member
640 Points
150 Posts
Re: How to post pictures to controller
Feb 12, 2021 06:44 AM|SreejithGopinathan|LINK
You have to use IFormFile Interface of Asp.Net Core 5.0
You can define a DTO class with an IFormFile property, and use in combination with form having enctype - multipart/form-data