Skip to content

Instantly share code, notes, and snippets.

@drawcode
Last active February 21, 2017 09:44
Show Gist options
  • Save drawcode/1be19966d79e1e81392ecbc68fc6044b to your computer and use it in GitHub Desktop.
Save drawcode/1be19966d79e1e81392ecbc68fc6044b to your computer and use it in GitHub Desktop.
var fileUpload = $(".files-upload").get(0);
var files = fileUpload.files;
var data = new FormData();
for (var i = 0; i < files.length ; i++) {
data.append(files[i].name, files[i]);
}
data.append("test", "1");
$.ajax({
type: "POST",
url: "/api/v1/files/",
contentType: false,
processData: false,
data: data,
success: function (message) {
console.log(message);
},
error: function () {
console.log("There was error uploading files!");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment