PHP
Chilkat2 PHP
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 Downloads
<?php
use Chilkat2\BinData;
$bd = new BinData();
try {
$bd->LoadFile('qa_data/jpg/starfish.jpg');
} catch (\Chilkat2\Exception $e) {
echo "Failed to load file.\n";
exit;
}
echo $bd->GetEncoded('base64'), "\n";
// If you want mult-line base64:
echo "--\n";
echo $bd->GetEncoded('base64_mime'), "\n";
// If you want hex..
echo "--\n";
echo $bd->GetEncoded('hex'), "\n";
// etc..