Upload photo with ASP NET CORE Web API

Developer: Roman Zapotockiy (dobbikov)

Upload files to server with ASP NET Core web api.

Stack

  • BackEnd
    • ASP NET Core
  • FrontEnd
    • React JS

Setup

  1. Install
  1. Write to cmd: npm install
  2. Start .NET Project

Usage

Upload photo with http rest api http://domain/api/Upload/Upload

Example:

  const uploadPhotoHandler = async event => {
    let fd = new FormData();
    fd.append('formFile', event.target.files[0]);
    fd.append('fileName', event.target.files[0].name);
    const req = await fetch('/api/Upload/Upload', {method: 'POST', body: fd});
    const data = req.json();
  }