![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Visual FoxPro) Download Image (JPG, GIF, etc.) to Base64See more HTTP ExamplesDemonstrates how to download an image, or any type of file, to get the data in base64 encoding format.
LOCAL lnSuccess LOCAL loHttp LOCAL loBd LOCAL lnStatusCode LOCAL lcBase64_image_data lnSuccess = 0 * This example requires the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. loHttp = CreateObject('Chilkat.Http') loHttp.KeepResponseBody = 1 loBd = CreateObject('Chilkat.BinData') lnSuccess = loHttp.DownloadBd("https://www.chilkatsoft.com/images/starfish.jpg",loBd) lnStatusCode = loHttp.LastStatus IF (lnSuccess = 0) THEN IF (lnStatusCode = 0) THEN * Unable to either send the request or get the response. ? loHttp.LastErrorText ELSE * We got a response, but the status code was not in the 200s ? "Response status code: " + STR(lnStatusCode) * Examine the response body. ? "Response body:" ? loHttp.LastResponseBody ENDIF ? "Download failed." ELSE ? "Download success, response status = " + STR(lnStatusCode) lcBase64_image_data = loBd.GetEncoded("base64") ? "image data in base64 format:" ? lcBase64_image_data ENDIF RELEASE loHttp RELEASE loBd |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.