Skip to content

Instantly share code, notes, and snippets.

@madeinfree
Last active July 23, 2021 07:58
Show Gist options
  • Save madeinfree/6ab44cbd6b00838ca7b7f86e92d4f584 to your computer and use it in GitHub Desktop.
Save madeinfree/6ab44cbd6b00838ca7b7f86e92d4f584 to your computer and use it in GitHub Desktop.
上傳圖片
<input type="file" />
const input = document.getElementById('file')
input.addEventListener('change', (e) => {
const file = e.target.files[0]
const formData = new FormData()
formData.append('file', file)
axios.post(`${AWS API Gateway endpoint}`, formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
}).then(r => {
console.log(r)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment