Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Visual FoxPro Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text

HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(Visual FoxPro) REST File Upload (multipart/form-data)

Demonstrates how to upload a file using multipart/form-data.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

LOCAL loRest
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL lnSuccess
LOCAL loFileStream
LOCAL lcResponseBody

*  This example requires the Chilkat API to have been previously unlocked.
*  See Global Unlock Sample for sample code.

loRest = CreateObject('Chilkat_9_5_0.Rest')

*  Connect to the HTTP server using TLS.
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
*  Make sure to replace "www.chilkatsoft.com" with your domain..
lnSuccess = loRest.Connect("www.chilkatsoft.com",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    CANCEL
ENDIF

loFileStream = CreateObject('Chilkat_9_5_0.Stream')
loFileStream.SourceFile = "qa_data/jpg/starfish.jpg"

loRest.AddHeader("Content-Type","multipart/form-data")

loRest.PartSelector = "1"
loRest.AddHeader("Content-Type","image/jpg")
loRest.AddHeader("Content-Disposition",'form-data; name="filename"; filename="starfish.jpg"')
loRest.SetMultipartBodyStream(loFileStream)
loRest.PartSelector = "0"

lcResponseBody = loRest.FullRequestMultipart("POST","/the_uri_path_to_receive_the_upload")
IF (loRest.LastMethodSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loFileStream
    CANCEL
ENDIF

IF (loRest.ResponseStatusCode <> 200) THEN
    ? "Received error response code: " + STR(loRest.ResponseStatusCode)
    RELEASE loRest
    RELEASE loFileStream
    CANCEL
ENDIF

? "File uploaded"

RELEASE loRest
RELEASE loFileStream


 

© 2000-2019 Chilkat Software, Inc. All Rights Reserved.