I have an html form which i parse to json and send it to my java- backend.
        var data = {};
        var formArray = $("#form").serializeArray();
        $.each(formArray, function (i, field) {
            if(field.name !== '') {
                data[field.name] = field.value;
            }
        });
        $.ajax({
            type: "POST",
            url: encodedContextPath + "/form/send",
            data: JSON.stringify(data),
            dataType: "json",
            contentType: 'application/json'
            ........
Now i need to add the ability to also upload a pdf file, how can i put this file into my json which i'll send to the backend? Can i serialize it somehow or generate a data stream which i can put into the json?
 
    