Sample code for 30+ languages & platforms
PHP Extension

Load Entire File into BinData

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

Chilkat PHP Extension Downloads

PHP Extension
<?php

include("chilkat.php");

$success = false;

$fac = new CkFileAccess();

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

$bd = new CkBinData();
$maxBytesToRead = 99999999;
$success = $fac->FileReadBd($maxBytesToRead,$bd);
if ($success == false) {
    print $fac->lastErrorText() . "\n";
    exit;
}

$fac->FileClose();

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

?>