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'
}
})
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'
}
})
uploadFile: function (event) {
const file = event.target.files[0]
axios.post('upload_file', file, {
headers: {
'Content-Type': file.type
}
})
}
const photoFormData = new FormData();
// dict of all elements
photoFormData.append("avatar", file);
photoFormData.append("email", this.state.email);
photoFormData.append("name", this.state.name);
let headers = {
Authorization: "token",
'Content-Type':'multipart/form-data'
};
let formData = new FormData();
for(let key in files){
formData.append('files[][file]', files[key].file, files[key].file.name)
formData.append('files[][file_type_id]', files[key].fileType)
}
axios
.post(
"/api/files",
formData,
{ headers }
)
.then(()=>{console.log('It Works')})