Reputation: 512
I have a multipart form where the first part of the request is the form data and the second part is a file. The first part of the request is missing a filename and the second part has an empty payload where the binary contents should show.
A sample payload is as follows:
------WebKitFormBoundaryiCmJmbQ7e518oDt9
Content-Disposition: form-data; name="message"
{"category":"OTHER","subject":"Test","body":"testttt"}
------WebKitFormBoundaryiCmJmbQ7e518oDt9
Content-Disposition: form-data; name="test.pdf"; filename="test.pdf"
Content-Type: application/pdf
------WebKitFormBoundaryiCmJmbQ7e518oDt9--
The first content-disposition is missing filename="message". I've tried changing this into a Blob, but then the payload is empty. No matter what I try, I can't get the file to show in the payload. It should show something like �PDF
My ajax request:
var data = new FormData();
data.append('message', JSON.stringify(message.attributes));
data.append(document.getElementById('fileInput').files[0].name,document.getElementById('fileInput').files[0]);
message.save({},{
cache: false,
contentType: false,
processData: false,
data: data
});
Upvotes: 2
Views: 2191