Sample code for 30+ languages & platforms
PHP ActiveX

Example: Http.HttpBinary method

Demonstrates the HttpBinary method.

Chilkat PHP ActiveX Downloads

PHP ActiveX
<?php

$success = 0;

$localFilePath = 'C:/example/zips/data.zip';

$bd = new COM("Chilkat.BinData");
$success = $bd->LoadFile($localFilePath);
if ($success == 0) {
    print $bd->LastErrorText . "\n";
    exit;
}

$zipBytes = $bd->GetData();

$url = 'https://example.com/api/v1/sites/123/deploys';

// Send a POST with a binary HTTP request body.
$resp = new COM("Chilkat.HttpResponse");
$http = new COM("Chilkat.Http");

$success = $http->HttpBinary('POST',$url,$zipBytes,'application/zip',$resp);
if ($success == 0) {
    print $http->LastErrorText . "\n";
    exit;
}

print 'Response Status Code: ' . $resp->StatusCode . "\n";
print 'Response body:' . "\n";
print $resp->BodyStr . "\n";

?>