HttpPostedFileBase
I want to solve this problem to store the image to the database. I still don't run the project, if I have errors or an easier way to do it
public IActionResult Create(Productos prod [Bind("codigoFoto"] Productos productos, HttpPostedFileBase FotoProducto)
{
//Console.WriteLine(JObject.FromObject(prod));
using (var _context = new ApplicationDbContext())
{
var Categoria = _context.Categorias.Where(i => i.IsActive && i.Id == prod.Categoria.Id).FirstOrDefault();
if (prod != null)
{
if (FotoProducto != null && FotoProducto.ContentLength > 0)
{
byte[] imageData = null;
using (var binaryReader = new BinaryReader(FotoProducto.InputStream))
{
imageData = binaryReader.ReadBytes(FotoProducto.ContentLength);
}
//setear la imagen a la entidad que se creara
productos.Foto = imageData;
}