Perl
Perl
Base64 Encode a File
_LANGUAGE_ to Base64 encode the contents of a file.Chilkat Perl Downloads
use chilkat();
$success = 0;
# Get the contents of a file into a base64 encoded string:
$fac = chilkat::CkFileAccess->new();
$strBase64 = $fac->readBinaryToEncoded("c:/data/something.pdf","base64");
if ($fac->get_LastMethodSuccess() != 1) {
print $fac->lastErrorText() . "\r\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() . "\r\n";
exit;
}
print "Success!" . "\r\n";