Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js send file as form input

var input = document.querySelector('input[type="file"]')

var data = new FormData()
data.append('file', input.files[0])
data.append('user', 'hubot')

fetch('/avatars', {
  method: 'POST',
  body: data
})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #send #file #form #input
ADD COMMENT
Topic
Name
9+5 =