Skip to content

Instantly share code, notes, and snippets.

@eufelipemateus
Created December 12, 2021 01:16
Show Gist options
  • Save eufelipemateus/59ad8532d00c4079acaba3615bcacded to your computer and use it in GitHub Desktop.
Save eufelipemateus/59ad8532d00c4079acaba3615bcacded to your computer and use it in GitHub Desktop.
document.querySelector('input[type="file"]').onchange = async function(e){
const files = this.file
const formData = new FormData();
formData.append('file', files[0]);
const res = await axios.post('/files', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment