We can just as easily use
some other settings, perhaps specified in a component configuration.
To use the JFTP class we must first import and create a new instance of the class. We
use the static JTFP getInstance() method to create a new instance of the class. This
example does just the same:
jimport('joomla.client.ftp');
$client =& JFTP::getInstance($FTP_Settings['host'],
$FTP_Settings['port'],
APIs and Web Services
[ 298 ]
null,
$FTP_Settings['user'],
$FTP_Settings['pass']);
The third parameter, in the above example set to null, is an optional associative
array of FTP options. This array can contain the type and timeout keys:
type is used to determine the FTP connection mode, either of FTP_
AUTOASCII, FTP_BINARY, or FTP_ASCII; the default mode is FTP_BINARY.
timeout is used to set the maximum time, in seconds, which should lapse
before the FTP connection timeouts. PHP versions prior to 4.3.0 do not
support the timeout option.
The great thing about using the getInstance() method is that the returned object
will already have created a connection to the FTP server and authenticated itself.
Pages:
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410