Sample code for 30+ languages & platforms
PHP ActiveX

Load Entire File into BinData

Demonstrates how to load an entire file into a BinData object.

Chilkat PHP ActiveX Downloads

PHP ActiveX
<?php

$success = 0;

$fac = new COM("Chilkat.FileAccess");

$success = $fac->OpenForRead('qa_data/pdf/sample.pdf');
if ($success == 0) {
    print $fac->LastErrorText . "\n";
    exit;
}

$bd = new COM("Chilkat.BinData");
$maxBytesToRead = 99999999;
$success = $fac->FileReadBd($maxBytesToRead,$bd);
if ($success == 0) {
    print $fac->LastErrorText . "\n";
    exit;
}

$fac->FileClose();

// The bd object contains the file data...
$success = $bd->WriteFile('qa_output/sample.pdf');

?>