PHP ActiveX
PHP ActiveX
Base64 Encode a File
_LANGUAGE_ to Base64 encode the contents of a file.Chilkat PHP ActiveX Downloads
<?php
$success = 0;
// Get the contents of a file into a base64 encoded string:
$fac = new COM("Chilkat.FileAccess");
$strBase64 = $fac->readBinaryToEncoded('c:/data/something.pdf','base64');
if ($fac->LastMethodSuccess != 1) {
print $fac->LastErrorText . "\n";
exit;
}
// Now write the string to a file:
$success = $fac->WriteEntireTextFile('c:/data/something_pdf_base64.txt',$strBase64,'us-ascii',0);
if ($success != 1) {
print $fac->LastErrorText . "\n";
exit;
}
print 'Success!' . "\n";
?>