(Classic ASP) Base64 Encode a File
Classic ASP to Base64 encode the contents of a file.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
' Get the contents of a file into a base64 encoded string:
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.FileAccess")
set fac = Server.CreateObject("Chilkat.FileAccess")
strBase64 = fac.ReadBinaryToEncoded("c:/data/something.pdf","base64")
If (fac.LastMethodSuccess <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( fac.LastErrorText) & "</pre>"
Response.End
End If
' Now write the string to a file:
success = fac.WriteEntireTextFile("c:/data/something_pdf_base64.txt",strBase64,"us-ascii",0)
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( fac.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "Success!") & "</pre>"
%>
</body>
</html>
|