I have a .pdf file client side that I would like to send in binary form to my server, which will be handling it with PHP.
Client side, I am using a POST request that looks like this:
var newFile = require("sdk/io/file");
var params = {};
params.log = newFile.read(filepath, "b");
var makeRequest = newRequest({
url: "SERVERURL",
headers: {
"Content-Type": "application/pdf"
},
content: params,
onComplete: function(response) {
console.error(response.text);
}
}).post();
On server side, I'm using
file_get_contents('php://input')
and file_put_contents to write to a path on the server.
I have tried base64_decode and urldecode on the input, neither of which have correctly regenerated the PDF on the server. With urldecode, I get a blank PDF with the correct number of pages, but no text.
I'm new to PHP, could someone help me out?
Thank you.