File upload with ASP.Net Core 2.0 Web API and React.js

后端 未结 4 520
忘了有多久
忘了有多久 2021-02-03 13:30

I\'m new to both react.js and ASP.Net core 2.0. And now writing a project using ASP.Net core 2.0 as back end API and react.js as application interface (front end). I\'d like to

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-03 13:38

    In my case i simply missed to add multipart/form-data in my form.

    If your controller is accepting uploaded files using IFormFile but you find that the value is always null, confirm that your HTML form is specifying an enctype value of multipart/form-data. If this attribute isn't set on the element, the file upload won't occur and any bound IFormFile arguments will be null.

    Example:-

    Upload one or more files using this form:

    Remove the multiple attribute on this input element to allow just a single file to be uploaded.

提交回复
热议问题