Skip to content

Instantly share code, notes, and snippets.

@lwakefield
Last active June 1, 2016 17:04
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 lwakefield/b7ca787eb33d5dbb0205dad76e6e7add to your computer and use it in GitHub Desktop.
Save lwakefield/b7ca787eb33d5dbb0205dad76e6e7add to your computer and use it in GitHub Desktop.
<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