Upload file to Asp.net core by fetch

Asked

Viewed 48 times

1

I’m editing the previous question.

This function traverses a table with input file and plays in a formData but sent by fetch at the asp.net core is coming null

function uploadFiles() {


let inputFile;
let formData = new FormData();

jQuery('#tblDocumentosAnexos > tbody > tr').each(function () {
         inputFile = jQuery(this).find('td').eq(2).children()[0].files[0];
        formData.append("arquivos", inputFile, inputFile.name);
  });

console.log(formData);

fetch('upload', {
    method: 'POST',
    body: formData
})}

Method in Asp.net core

    [Route("upload")]
    [HttpPost]
    public void Upload(List<IFormFile> files)
    {

    }
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.