Please enable JavaScript to view this site.

DAQFactory User's Guide

Navigation: 12 Networking / Connectivity

12.5 FTP

Scroll Prev Top Next More

With DAQFactory you can FTP to remote servers and upload and download files.  Use this to upload data files to a server to share, or even generate dynamic HTML with the File. functions and then upload them to your webserver.  FTP is implemented like Email, using an object and a collection of member variables and functions.  The object is CFTP and must be instantiated first.  For example:

 

private sFTP = new(CFTP)

FTP.strServer = "ftp.myISP.com"

FTP.strLocalFile = "c:\myData\data.csv"

FTP.strRemoteFile = "data.csv"

...

FTP.Upload()

If you want to FTP to multiple sites simultaneously, or send multiple files, or send from multiple sequences, you should instantiate a new CFTP object for each communications link.  

Note that there is an internal object called "FTP" that has the same variables and functions provided for backwards compatibility.  Using this object is less flexible as it only supports one communications link at a time and you have to be sure its done with its upload / download before doing another file.

strServer: the name of your FTP server.  For example: sFTP.strServer = "ftp.myISP.com"

strUserName: your FTP username

strPassword: your FTP password (optional)

strLocalFile: the full path to the file you are uploading, or the place to put the downloaded file.

strRemoteFile: the path on the remote server where you'd like the uploaded file placed, or the path to the file you'd like to download.

Port: the port to use for FTP.  This defaults to 21.

Timeout: the connection timeout in milliseconds.  This defaults to 3000, or 3 seconds.

BytesTransfered: during the transfer, you can read this value to determine the progress of the transfer.

BytesToTransfer: during the transfer, if available, this tells you how big the file to transfer is.

Upload(): Once you have set the desired variables, call the FTP.Upload() function to actually start the FTP Upload.

Download(): Once you have set the desired variables, call the FTP.Download() function to actually start the FTP Download.

Upload() and Download() run the FTP transfer asynchronously.  This means the functions will return immediately.  To determine the progress of the FTP transfer, use the BytesTransfered / BytesToTransfer variables.  Note that you can only run one FTP transfer at a time on a single CFTP and will receive an error if you try to do otherwise.  If you want to run multiple transfers, simply instantiate new CFTP objects.  Note that some servers may limit the number of simultaneous connections.

Abort(): Stops an FTP transfer that is running.