Last active
June 1, 2016 17:04
-
-
Save lwakefield/b7ca787eb33d5dbb0205dad76e6e7add to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="file"> | |
<script> | |
var el = document.querySelector('input[type="file"]'); | |
el.addEventListener('change', function(event) { | |
let files = e.target.files; | |
for (let i = 0; i < files.length; i++) { | |
let file = files[i]; | |
var xhr = new XMLHttpRequest(); | |
// set the url to wherever you meteor app is running | |
xhr.open('PUT', 'http://localhost:3000/file', true); | |
xhr.onload = (event) => { | |
console.log('done uploading!'); | |
}; | |
xhr.upload.onprogress = (event) => { | |
let percent = 100 * (event.loaded / event.total); | |
console.log(percent+'% uploaded'); | |
}; | |
xhr.send(file); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment