Skip to content

Instantly share code, notes, and snippets.

@sarumont
Last active December 10, 2015 00:28
Show Gist options
  • Save sarumont/4351076 to your computer and use it in GitHub Desktop.
Save sarumont/4351076 to your computer and use it in GitHub Desktop.
<iframe id="upload_target" style="display:none;width:0;height:0"></iframe>
<form action="<upload handler>" target="upload_target" enctype="multipart/form-data" method="post">
<input type="file" name="file" />
</form>
<form action="<upload handler>" enctype="multipart/form-data" method="post">
<input type="file" name="file" />
</form>
function sendForm(form) {
var formData = new FormData(form);
var req = new XMLHttpRequest();
req.open("POST", "<upload handler>");
req.send(formData);
return req;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment