ASP.Core Uploading image with Axios

vue axios file upload
axios upload file node js
axios upload multiple files
react axios file upload
axios iformfile
axios upload large file
react upload image
axios multipart/form-data

I am trying to upload an image to a server with Axios, but having Error 400 "Bad Request". I have tried many different ways to implement it: explicitly specifying a "Content-Type", changing controller, trying $.ajax, etc. from Google.

A brief description of what I am expecting: I choose an image as suggested by <input/> and once I submit my choice it is sent to the server.

Currently, in my controller, I set a breakpoint, however, I've never seen request entering it.

My stack is Asp.Core WebAPI + React.js + Axios. I have stopped on the following code:


public class CharacterController : ControllerBase
    public async Task<IActionResult> SetProfilePhoto(IFormFile file)
        return Ok();

React Component:

export default class BioEdit extends React.Component {
        changePhoto = event => {

             const file =[0];

             const formData = new FormData();
             formData.append("File", file);

   "api/char/SetProfilePhoto", formData, {
                  headers: { 'Content-Type': 'multipart/form-data' }
                  .catch(error => console.log(error));
             return (
                 <label >
                     <img src={this.state.char.image} width="30%" height="30%" className="border border-secondary" />
                     <input type="file" style={{ display: "none" }} accept="image/*" onChange={this.changePhoto} />

Here is what I have in the browser (Yandex browser it is to be specific, based on Chrome):

But React Native didn't make it. React Native function uploadPhoto = async response => { const data = new FormData(); data.append("image",  Dismiss Join GitHub today. GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.

add undefined content type. it should work then
"api/char/SetProfilePhoto", formData, {
              headers: { 'Content-Type': undefined }

In this article, see how to upload files using ASP. we will learn how to upload files, images or videos using ASP. npm install --save axios. ASP.NET Core FileUpload with Vue.JS & Axios. This repository has package.json with installed Babel loader, webpack & npm. A simple file upload that supports multiple file upload.

In this article, you will learn about file upload using ASP. this tutorial, we will learn how to upload files, Images or Videos using Web API and ReactJS. Now Install the Axios library by using the following command. Post Data From VueJs To ASP.NET CORE Using Axios Published on July 28, 2017 July 28, 2017 • 30 Likes • 9 Comments

In this tutorial I'm going to be using Axios v0.16.2 and VueJS v2.1.0 for doing the file uploads. On the back end you can use the framework that  Hi, I am trying to upload blob (image) along with some params, but no matter what I can't seem to put the data in the body of the request. let blob = new Blob(, {type: 'image/png'}); API_URL + 'v1/files/upload/'

Part 2 of 4 in Your Guide To Uploading Files with VueJS and Axios a preview for uploaded images before they are submitted: Preview File Uploads with Axios and VueJS. This method contains the core of our functionality. Upload a photo and verify that the thumbnail is shown. Click the thumbnail to see the full-size image. In the images and images/thumbs, note that new files have been added. Rotating and Flipping an Image. The WebImage helper also lets you flip and rotate images. This procedure shows how to get an image from the server, flip the image upside

On the backend we will use ASP.NET Core MVC to expose an endpoint to the client to receive file. Let's say we have a HTML form for saving a coffee, this form contains a file input to accept coffee's image: Now we want to show upload progress, axios makes this easy all we need to do is add a third  Upload files to a dedicated file upload area, preferably to a non-system drive. A dedicated location makes it easier to impose security restrictions on uploaded files. Disable execute permissions on the file upload location.† Do not persist uploaded files in the same directory tree as the app.† Use a safe file name determined by the app.