FTP functions

The FTP functions can be used for uploading or downloading files from a web server (Zorro 1.16 and above).

ftp_download(string url, string path, string username, string password)

Downloads a file from a FTP server.

ftp_upload(string url, string path, string username, string password)

Uploads a file to a FTP server.

ftp_getdate(string url, string username, string password)

Ascertains the timestamp and the file size of a file stored on a FTP server.

ftp_stop()

Stops the currently running FTP transfer.

ftp_size(): long

Returns the total file size of the current/last file in bytes.

ftp_sent(): long

Returns the amount of sent data of the current/last file in bytes.

ftp_timestamp(): long

Returns the timestamp of the current/last file, after ftp_getdate() was executed successfully.

ftp_status()

Returns the status of a currently running or the last FTP transfer:

-1 if the last FTP transfer was stopped because of an error
0 if the FTP transfer is still running
1 if the last FTP transfer was successful

ftp_log (var mode)

Enables/disables the logging of FTP transfers. The logfile is named "ftp_log.txt".

Parameters:

url - URL of the file to be downloaded, or destination URL for a file upload (e.g.: "ftp://www.testhoster.com/downloads/test.txt").
path - local path + filename (e.g.: "testdir/test.txt")
username - FTP username
password - FTP password
mode - 1 to enable, 0 to disable FTP logging

Remarks:

Example:

function main() 
{ 
//Downloads the file "myfile.txt" and saves it in the Data folder 
  ftp_download("ftp://www.testhost.com/files/myfile.txt","Data/myfile.txt","username","password"); 
  while(!ftp_status()) //as long as the download is running
    Sleep(50);
  if (ftp_status() == 1) 
    printf("\nDownload successful!"); 
  else 
    printf("\nDownload failed!"); 
}

See also:

http functions, file functions

► latest version online