toBase64

Calculates the Base64 representation of a string or binary
object. The Base64 format uses printable characters, allowing
binary data to be sent in forms and e-mail, and stored in a
database or file.

toBase64(string_or_object [, encoding]) → returns string

Argument Reference

string_or_object any
Required

A string, the name of a string, or a binary object.

encoding string

For a string, defines how characters are represented in a
byte array.
Values:
  • utf-8
  • iso-8859-1
  • windows-1252
  • us-ascii
  • shift_jis
  • iso-2022-jp
  • euc-jp
  • euc-kr
  • big5
  • euc-cn
  • utf-16

Links more information about toBase64

Examples
Sample code invoking the toBase64 function

Converts a String to a Base64-String.

ToBase64("Test String")

Expected Result: VGVzdCBTdHJpbmc=

Converts an Image Binary to a Base64-String.

ToBase64(ToBinary(ImageRead("example.jpg")))

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub