(VBScript) Download Image (JPG, GIF, etc.) to Base64
Demonstrates how to download an image, or any type of file, to get the data in base64 encoding format.
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Http")
set http = CreateObject("Chilkat.Http")
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.BinData")
set bd = CreateObject("Chilkat.BinData")
success = http.DownloadBd("https://www.chilkatsoft.com/images/starfish.jpg",bd)
If (success = 0) Then
outFile.WriteLine(http.LastErrorText)
WScript.Quit
End If
base64_image_data = bd.GetEncoded("base64")
outFile.WriteLine("image data in base64 format:")
outFile.WriteLine(base64_image_data)
outFile.Close
|