PHP Extension Requires Chilkat v11.0.0+
PHP Extension
HTTP POST with Binary Data in Request Body
See more HTTP Examples
Do an HTTPS POST with a binary request body.Chilkat PHP Extension Downloads
<?php
include("chilkat.php");
$success = false;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
$http = new CkHttp();
$fac = new CkFileAccess();
$reqBody = new CkByteData();
$success = $fac->ReadEntireFile('qa_data/pdf/helloWorld.pdf',$reqBody);
$resp = new CkHttpResponse();
$success = $http->HttpBinary('POST','https://example.com/something',$reqBody,'application/pdf',$resp);
if ($success == false) {
print $http->lastErrorText() . "\n";
exit;
}
$responseStatusCode = $resp->get_StatusCode();
print 'Status code: ' . $responseStatusCode . "\n";
// For example, if the response is XML, JSON, HTML, etc.
print 'response body:' . "\n";
print $resp->bodyStr() . "\n";
?>