Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
|
Secure FTP (FTPS) Upload and Download
Visual Foxpro example program showing how to do FTPS (Secure FTP) file transfers.
* This Visual Foxpro FTPS sample shows to how do secure FTP uploads and
* downloads using AUTH TLS.
* Secure FTP (FTPS) using AUTH TLS
*
* What is TLS?
* Transport Layer Security (TLS) is the successor to
* Secure Sockets Layer (SSL). It is a cryptographic protocol that
* provides secure communications on the Internet for such things as
* email, FTP, and other data transfers. There are slight differences
* between SSL 3.0 and TLS 1.0, but the protocols are substantially the
* same.
* The most common method of doing secure FTP file transfers is
* by AUTH TLS (also known as AUTH SSL).
* The client connects on the standard unencrypted FTP port 21
* and then issues an "AUTH TLS" command to convert the TCP/IP channel
* to a TLS encrypted channel. All communications from that point onward,
* including data transfers, are encrypted.
LOCAL loFtp, lnSuccess, lcLocalFilename, lcRemoteFilename
loFtp = CreateObject('Chilkat.Ftp2')
loFtp.UnlockComponent('Anything for 30-day trial')
* Set the AuthTls property = 1.
loFtp.AuthTls = 1
* Leave the Ssl property = 0. The Ssl property is used
* for doing Secure FTP over SSL on port 990 (implicit SSL)
* FTP Implicit SSL is covered in another example.
loFtp.Ssl = 0
loFtp.HostName = "ftp.myHost.com"
loFtp.Username = "myLogin"
loFtp.Password = "myPassword"
* Connect and login to the FTP server. This establishs a control connection
* to the FTP server (port 21), converts the channel to TLS (because AuthTls is true),
* and then authenticates.
lnSuccess = loFtp.Connect()
IF ( lnSuccess = 0 )
=MESSAGEBOX(loFtp.LastErrorText)
RELEASE loFtp
RETURN .T.
ENDIF
* You may need to clear the control channel if your FTP client
* is located behind a network-address-translating router
* such as with a Cable/DSL router.
* =loFtp.ClearControlChannel()
* Download a file, keeping the same filename on the FTP server.
lcLocalFilename = "myFile.txt"
lcRemoteFilename = "myFile.txt"
lnSuccess = loFtp.GetFile(lcRemoteFilename, lcLocalFilename)
IF ( lnSuccess = 0 )
=MESSAGEBOX(loFtp.LastErrorText)
RELEASE loFtp
RETURN .T.
ENDIF
* Note: if PutFile fails and you get this in your LastErrorText:
* PortReply: 530 Only client IP address allowed for PORT command.
* It indicates that you must first clear the control channel
* because your FTP client sits behind a router doing NAT (network
* address translation). The router is not able to translate the
* IP address in the PORT command if the control channel is encrypted.
* To upload a file, use PutFile instead of GetFile. Note: the order
* of local/remote filenames is reversed:
lnSuccess = loFtp.PutFile(lcLocalFilename, lcRemoteFilename)
IF ( lnSuccess = 0 )
=MESSAGEBOX(loFtp.LastErrorText)
RELEASE loFtp
RETURN .T.
ENDIF
=loFtp.Disconnect()
RELEASE loFtp
RETURN .T.
|
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.
Mail Component · .NET Email Component · ASP Mail Component · XML Parser