Sample code for 30+ languages & platforms
PHP ActiveX

Get Contents of File as Base64

See more Encryption Examples

Demonstrates how to read the contents of a file and convert to a base64 string.

Chilkat PHP ActiveX Downloads

PHP ActiveX
<?php

$success = 0;

$bd = new COM("Chilkat.BinData");

$success = $bd->LoadFile('qa_data/jpg/starfish.jpg');
if ($success == 0) {
    print 'Failed to load file.' . "\n";
    exit;
}

print $bd->getEncoded('base64') . "\n";

// If you want mult-line base64:
print '--' . "\n";
print $bd->getEncoded('base64_mime') . "\n";

// If you want hex..
print '--' . "\n";
print $bd->getEncoded('hex') . "\n";

// etc.

?>