Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
FormData Example with File from the input element
var file = $('#order_file').prop('files')[0];
var form_data = new FormData();
$.each($('#ordercreate').serializeArray(), function (key, input) {
if (form_data.has( {
form_data.set(, input.value);
} else {
form_data.append(, input.value);
// console.log(form_data); // This will return an empty object, so dont worry!
for (var key of form_data.entries()) {
console.log(key[0] + ', ' + key[1]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment