Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

axios file upload

const formData = new FormData();
const imagefile = document.querySelector('#file');
formData.append("image", imagefile.files[0]);
axios.post('upload_file', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
})
Comment

axios send file

var formData = new FormData();
var imagefile = document.querySelector('#file');
formData.append("image", imagefile.files[0]);
axios.post('upload_file', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
})
Comment

upload file axios

uploadFile: function (event) {
    const file = event.target.files[0]
    axios.post('upload_file', file, {
        headers: {
          'Content-Type': file.type
        }
    })
}
Comment

axios send file with data

const photoFormData = new FormData();
    // dict of all elements
    photoFormData.append("avatar", file);
    photoFormData.append("email", this.state.email);
    photoFormData.append("name", this.state.name);
Comment

PREVIOUS NEXT
Code Example
Javascript :: scroll to top js 
Javascript :: patch request javascript 
Javascript :: if else js 
Javascript :: add numbers in array 
Javascript :: nest navigation react navigation 
Javascript :: timestamp convert moment vue 
Javascript :: os module in node js 
Javascript :: javascript write to text file 
Javascript :: react tostify 
Javascript :: how to check if value is undefines if condition jquery 
Javascript :: get current time in different timezone javascript 
Javascript :: create app with a specific react version 
Javascript :: is checked checkbox jquery 
Javascript :: string json to class c# 
Javascript :: javascript if string empty 
Javascript :: jquery set span text by id 
Javascript :: jquery change query string parameter value 
Javascript :: change p text jqwuery 
Javascript :: array join javascript 
Javascript :: javascript string remove substring 
Javascript :: js double exclamation mark 
Javascript :: nginx react router 
Javascript :: javascript count no of lines 
Javascript :: electron how to setup preload.js 
Javascript :: on load page javascript 
Javascript :: Link vs NavLink in react-router-dom 
Javascript :: es6 method definition syntax 
Javascript :: adding element to javascript object 
Javascript :: async awiat 
Javascript :: momentjs format date 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =