AutoIt
AutoIt
Download Image (JPG, GIF, etc.) to Base64
See more HTTP Examples
Demonstrates how to download an image, or any type of file, to get the data in base64 encoding format.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.KeepResponseBody = True
$oBd = ObjCreate("Chilkat.BinData")
$bSuccess = $oHttp.DownloadBd("https://www.chilkatsoft.com/images/starfish.jpg",$oBd)
Local $iStatusCode = $oHttp.LastStatus
If ($bSuccess = False) Then
If ($iStatusCode = 0) Then
; Unable to either send the request or get the response.
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Else
; We got a response, but the status code was not in the 200s
ConsoleWrite("Response status code: " & $iStatusCode & @CRLF)
; Examine the response body.
ConsoleWrite("Response body:" & @CRLF)
ConsoleWrite($oHttp.LastResponseBody & @CRLF)
EndIf
ConsoleWrite("Download failed." & @CRLF)
Else
ConsoleWrite("Download success, response status = " & $iStatusCode & @CRLF)
Local $sBase64_image_data = $oBd.GetEncoded("base64")
ConsoleWrite("image data in base64 format:" & @CRLF)
ConsoleWrite($sBase64_image_data & @CRLF)
EndIf