Programming Reference Manual
 
Syntax
 
Encode64_File(FilePath)
 
Description
Return a base64-encoded string representing the binary contents of the specified file. This function reads the file directly into a native binary buffer and performs the base64 encoding without intermediate string conversion, making it significantly faster than reading a file into a string variable and passing it to Encode64. This is particularly beneficial for large binary files such as images, PDFs and other documents. Internally, the function uses the Chilkat BinData component for high-performance native encoding. If the file cannot be read (e.g. the file does not exist or is locked), an empty string is returned.
 
Parameter
Description
FilePath
Full path to the file to be encoded, e.g. "O:\Documenten\Upload\foto.jpg".
See Also
Example
Sub Main
Dim sBase64 As String
sBase64 = Encode64_File("O:\Documenten\Upload\foto.jpg")
If sBase64 <> "" Then
Debug.Print "Encoded length: " & Len(sBase64)
Else
Debug.Print "<span style='color: #004080; font-weight: bold;'>Error</span>: file could not be read."
End If
End Sub