I'm moving a site from a Windows machine to the online environment (Unix) both running PHP5. But have a problem to get my data properly posted on the Unix machine.
On the unix machine my Content-Length of the post is 20 bytes less. I have put the 2 POST next to each other and they are the same.
Hereby the code that works fine on the Windows machine
[HTML]$body = 'theData';
$boundary = "---------------------".substr(md5(rand(0,32000)),0,10);
$host = theHost;
$port = "8080";
$path = PathToScript;
$data ='--'.$boundary.'
Content-Disposition: form-data; name="theXML"
'.$body.'
--'.$boundary.'--
';
$thepost = 'POST '.$path.' HTTP/1.0
Content-Type: multipart/form-data; boundary='.$boundary.'
Host: '.$host.':8080
Content-Length: '.strlen($data).'
'.$data;
$res = "";
$fsp = fsockopen($host, $port, $errno, $errstr, 30);
if($fsp) {
fputs($fsp, $thepost);
while(!feof($fsp)) {
$res .= fgets($fsp, 128);
}
fclose($fsp);
return $res;
}
else {
return "Error: " . $errstr;
}[/HTML]
But when I run the code on the unix machine the POST fails
Hereby the actual POST
win
[HTML]POST /Onlchk HTTP/1.0
Content-Type: multipart/form-data; boundary=---------------------dcf9082a17
Host: thehost:8080
Content-Length: 495
Connection: close
-----------------------dcf9082a17
Content-Disposition: form-data; name="theXML"
<OnlineCheck>
<Header>
<BuyerAccountId>ID</BuyerAccountId>
<AuthCode>CODE</AuthCode>
<Type>QUICK</Type>
</Header>
<Item line="1">
<ManufacturerItemIdentifier></ManufacturerItemIdentifier>
<ResellerItemIdentifier/>
<DistributorItemIdentifier>1335085</DistributorItemIdentifier>
<Quantity>1</Quantity>
</Item>
</OnlineCheck>
-----------------------dcf9082a17--[/HTML]
UNIX
[HTML]POST /Onlchk HTTP/1.0
Content-Type: multipart/form-data; boundary=---------------------c7bc77c261
Host: thehost:8080
Content-Length: 477
Connection: close
-----------------------c7bc77c261
Content-Disposition: form-data; name="theXML"
<OnlineCheck>
<Header>
<BuyerAccountId>ID</BuyerAccountId>
<AuthCode>CODE</AuthCode>
<Type>QUICK</Type>
</Header>
<Item line="1">
<ManufacturerItemIdentifier></ManufacturerItemIdentifier>
<ResellerItemIdentifier/>
<DistributorItemIdentifier>1335085</DistributorItemIdentifier>
<Quantity>1</Quantity>
</Item>
</OnlineCheck>
-----------------------c7bc77c261--[/HTML]
Anyone an idea ?