Skip to content

Instantly share code, notes, and snippets.

@slavic18
Created March 8, 2017 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slavic18/ee86accde2c0fb1210185a929ff8e3d8 to your computer and use it in GitHub Desktop.
Save slavic18/ee86accde2c0fb1210185a929ff8e3d8 to your computer and use it in GitHub Desktop.
Send file trough native http request
var req = new XMLHttpRequest()
var file = new Blob(['This is a test'], { type: 'text/plain' })
var data = new FormData()
data.append('photo', file, 'test.txt')
req.open('POST', '/upload')
req.send(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment