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

Tcl 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

 

 

 

(Tcl) HTTPS Upload File to Web Server

Uploads a file to a web server using HTTPS.

Chilkat Tcl Extension Downloads

Chilkat Tcl Extension Downloads

load ./chilkat.dll

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

#  The ContentType, HttpVerb, and Path properties should
#  always be explicitly set.
set req [new_CkHttpRequest]

CkHttpRequest_put_HttpVerb $req "POST"
CkHttpRequest_put_Path $req "/receiveMyUpload.aspx"
CkHttpRequest_put_ContentType $req "multipart/form-data"

CkHttpRequest_AddStringForUpload $req "fileA" "fileA.txt" "This is the contents of file A" "utf-8"
set success [CkHttpRequest_AddFileForUpload $req "starfish.jpg" "qa_data/jpg/starfish.jpg"]
if {[expr $success != 1]} then {
    puts [CkHttpRequest_lastErrorText $req]
    delete_CkHttpRequest $req
    exit
}

set http [new_CkHttp]

#  ----------------------------------------------------------------------------
#  IMPORTANT:
#  HTTP uploads require a counterpart implementation on the server, written in any desired language
#  such as C#, Classic ASP, PHP, etc., which consumes the upload being sent.
#  See: ASP.NET Receive Upload
#  ----------------------------------------------------------------------------

#  Do the upload.
set useSslTls 1
# resp is a CkHttpResponse
set resp [CkHttp_SynchronousRequest $http "www.example.com" 443 $useSslTls $req]
if {[expr [CkHttp_get_LastMethodSuccess $http] != 1]} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttpRequest $req
    delete_CkHttp $http
    exit
}

puts "response status code = [CkHttpResponse_get_StatusCode $resp]"
puts "response body:"
puts [CkHttpResponse_bodyStr $resp]

delete_CkHttpResponse $resp


delete_CkHttpRequest $req
delete_CkHttp $http

 

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