0

Could someone help me?, im trying to post a file using postman and asp.net.core but i am having this error at the time of making the post and i do not know why. Here is my code:

[HttpPost("UploadFile/{id}")]    
public async Task<ActionResult<Foto>> PostFoto([FromForm]IFormFile archivo, int id)
{
    var fileName = System.IO.Path.Combine(_enviroment.ContentRootPath, "uploads", 
         archivo.FileName);
         await archivo.CopyToAsync(
    new System.IO.FileStream(fileName, System.IO.FileMode.Create));
    Foto foto = new Foto();
    foto.Nombre_Foto = archivo.FileName;
    foto.id_registroacciden = id;
    _context.Fotos.Add(foto);
    _context.SaveChanges();
        
    return Ok();     
}
so cal cheesehead
  • 2,515
  • 4
  • 29
  • 50

0 Answers0