Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

490
Views
Upload Files via JS to ASP.Net Core with IFormFile

I am trying to send a file and other data to an Asp-Core-BackEnd.

In the backendController, I read the file like:

IFormFile file = HttpContext.Request.Form.Files.First(); //don't work

HttpContext.Request.Form.TryGetValue("id", out id)  //works

Works for other Clients. But I want use the Api with JS.

My js-code (react) looks like this:

const formData = new FormData();      
formData.append('id', 123);
formData.append('files', files);  //don't work

const config = {
    headers: {
      'content-type': 'multipart/form-data; charset=utf-8; boundary="------";'
    }
  }
        
await axios.post(url, formData, config);

but Form.Files is an empty Array

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try this?

[HttpPost]
        public string getfile([FromForm] string id, [FromForm] IFormFile file) {
            return "success";
        }

enter image description here enter image description here

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!