PHP
Chilkat2 PHP
Base64 Encode a File
_LANGUAGE_ to Base64 encode the contents of a file.Chilkat PHP Downloads
<?php
use Chilkat2\FileAccess;
// Get the contents of a file into a base64 encoded string:
$fac = new FileAccess();
try {
$strBase64 = $fac->ReadBinaryToEncoded('c:/data/something.pdf', 'base64');
// Now write the string to a file:
$fac->WriteEntireTextFile('c:/data/something_pdf_base64.txt', $strBase64, 'us-ascii', false);
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
echo "Success!\n";