Back

File Methods

 ftp.GetFileDetails(file);

This will return an Array Object with the following keys: name, size, type, timestamp, user, group.

Size is in bytes. Type will be either 'File' or 'Directory'.

Example - File Details

var file = ftp.GetFileDetails( 'image.png' );
if (file) {
  var s = "Name: " + file.name + "\nType: " + file.type + "\nSize: " + file.size + " bytes\n" + file.timestamp + "\n\n";
   }
app.Alert(s);
  Copy  

Returns: Array Object or Boolean false on Error.
Use ftp.GetError() for error handling.


 ftp.DownloadFile(remote, local, mode);

This will download 'remote' file to 'local' storage. 'local' must be an absolute path (Example: '/sdcard/file.txt'). Mode accepts two options, 'ASCII' and 'BINARY'. Defaults to 'BINARY'.

Returns: boolean true or false
Use ftp.GetError() for error handling.


 ftp.UploadFile(local, remote, mode);

This will upload 'local' file to 'remote' server. 'remote' can be either relative to CurrentWorkingDirectory or an absolute path from FTP root. Mode accepts two options, 'ASCII' and 'BINARY'. Defaults to 'BINARY'.

Returns: boolean true or false
Use ftp.GetError() for error handling.

Example - Upload File

ftp.UploadFile('/sdcard/myimage.png', 'images/myimage.png', 'BINARY');
  Copy  

 ftp.DeleteFile(file);

This will delete 'file'. Without absolute paths, this will use the CurrentWorkingDirectory.

Returns: boolean true or false
Use ftp.GetError() for error handling.


 ftp.RenameFile(file, newName);

This will rename 'file' to 'newName'. Without absolute paths, this will use the CurrentWorkingDirectory.

Returns: boolean true or false
Use ftp.GetError() for error handling.

Example - Rename File

if (ftp.RenameFile('image.jpg', 'myimage.png')) { app.Alert( 'Rename was successful.' )};
  Copy  


 ftp.FileExists(file);

This will check if a 'file' exists on the server. The path to the file can be relative to CurrentWorkingDirectory or absolute from the FTP root. Use ftp.DirectoryExists for checking if a directory exists.

Returns: boolean true or false
Use ftp.GetError() for error handling.