I'm trying to send a file from nodejs using http post options to php server and when I'm using postman to post that file this is an image for postman:
when I post data (file and text) directly from postman to php server through this php code:
<?php
print_r($_FILES );
print_r($_REQUEST );
?>
I get the output like image above
but when I post the data from my nodejs server with this code:
class of http options:
export const postOptions: PostOptions = {
port: 80,
hostname: "127.0.0.1",
path: "/load.php",
method: "POST",
headers: {
"Content-Type": "multipart/form-data"
}
and this is the code of post request:
const objstatic = JSON.stringify({
uid: "yghu",
docfile: imageFile,
name: "554",
subRAId: "554"
});
const req = http.request(postOptions, res => {
console.log(`statusCode: ${res.statusCode}`);
res.on("data", d => {
process.stdout.write("----->" + d);
});
});
req.on("error", error => {
console.error(error);
});
req.write(objstatic);
req.end();
I got empty arrays:
Array(
)
Array(
)
so how post file and text from nodejs server to php server note: I have control over two servers