WebFtpWriteFile Function

Action

Writes data to a previously opened file on a remote server.

Include file

WebAPI.bdh

Syntax

WebFtpWriteFile(in hFtp : number, 
                        in sData : string, 
                        in nData : number, 
                        out nWritten : number): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
hFtp

Valid handle to an FTP session. This handle must have been returned from a previous call to WebFtpConnect.

Beside that, the file must have been opened using WebFtpOpenFile.

sData Buffer that contains the data to write
nData Number of bytes to write to the file
nWritten Variable that receives the number of bytes written

Example

dcltrans 
  transaction TWriteFile 
  var 
    hFtp : number; 
    sData : string(50); 
    nData : number; // number of bytes written 
  begin 
    sData := "Hello world!"; 
    WebFtpConnect(hFtp, "localhost", WEB_PORT_FTP, "user", "pass"); 
    WebFtpOpenFile(hFtp, "testfile.txt", false, true); 
    WebFtpWriteFile(hFtp, sData, Strlen(sData), nData); 
    write(nData); write(" bytes written"); writeln; 
    WebFtpCloseFile(hFtp); 
    WebFtpShutdown(hFtp); 
end TWriteFile;