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'
}
})Add the file to a formData object, and set the Content-Type header to multipart/form-data.
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'
}
})
Also in JavaScript:
- MDN array length
- vscode pylint disable Module name doesn't conform to snake_case naming style
- js draggable
- node.js crypto.createcipheriv
- javascript get cursor position without event
- js kill process
- endpoint js
- remove header border react native
- Cannot find module '.json'
- javascript change select options dynamically
- jquery continue in loop each
- s3 bucket as static website for angular
- javascript remove uniques from array
- angular coding examples
- string.find javascript
- javascript currency symbol format
- search string in file node
- how to close another browser tab with javascript
- javascript to remove duplicates from an array
- create new vuejs project
- Javascript remove last character
- style an element with javascript
- react buttons npm
- add parameter submit form javascript