Skip to content

Instantly share code, notes, and snippets.

@kevashcraft
Created September 1, 2015 18:56
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 kevashcraft/777ad40e07e27da376e0 to your computer and use it in GitHub Desktop.
Save kevashcraft/777ad40e07e27da376e0 to your computer and use it in GitHub Desktop.
fileUpload: function(e,d,o) {
if(this.$.upfile.value == null) return;
this.fileUploading = true;
var formData = new FormData();
formData.append('upfile', this.$.upfile.files[0], this.$.upfile.value );
formData.append('proposal', this.proposal.id);
var xhr = new XMLHttpRequest();
xhr.open('POST', '/jaxson/proposals/file_upload?token=' + BPC.user.token, true);
xhr.onload = function(e) {
if(xhr.status === 200) {
var response = JSON.parse(xhr.responseText);
this._jaxson(response);
}
}.bind(this);
xhr.send(formData);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment