Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) Asynchronous HTTPS Upload (TLS)Demonstrates how to do an HTTPS (TLS) upload asynchronously in a background thread. A server-side C# example showing how to receive an upload is located at C# ASP.NET Code to Receive Upload
IncludeFile "CkUpload.pb" Procedure ChilkatExample() upload.i = CkUpload::ckCreate() If upload.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Specify the page (ASP, ASP.NET, Perl, Python, Ruby, CGI, etc) ; that will process the HTTP Upload. CkUpload::setCkHostname(upload, "www.mywebserver.com") CkUpload::setCkPath(upload, "/receiveUpload.aspx") ; Add one or more files to be uploaded. CkUpload::ckAddFileReference(upload,"file1","dude.gif") CkUpload::ckAddFileReference(upload,"file2","pigs.xml") CkUpload::ckAddFileReference(upload,"file3","sample.doc") ; To upload using SSL/TLS (https), set the Ssl property = 1 CkUpload::setCkSsl(upload, 1) ; Begin the HTTP upload in a background thread: success.i = CkUpload::ckBeginUpload(upload) If success <> 1 Debug CkUpload::ckLastErrorText(upload) Else Debug "Upload started.." EndIf ; Wait for the upload to finish. ; Print the progress as we wait... While (CkUpload::ckUploadInProgress(upload) = 1) ; We can abort the upload at any point by calling: ; upload.AbortUpload(); ; Display the percentage complete and the number of bytes uploaded so far.. ; The total upload size will become set after the upload begins: Debug Str(CkUpload::ckPercentUploaded(upload)) + "% " + Str(CkUpload::ckNumBytesSent(upload)) + "/" + Str(CkUpload::ckTotalUploadSize(upload)) ; Sleep 2/10ths of a second. CkUpload::ckSleepMs(upload,200) Wend ; Did the upload succeed? If CkUpload::ckUploadSuccess(upload) = 1 Debug "Files uploaded!" Else Debug CkUpload::ckLastErrorText(upload) EndIf CkUpload::ckDispose(upload) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.