# Where to connect $ftp_host = 'ftp.mozilla.org'; # Some set-up $ftp_connection = new cFTP_Connection( $ftp_host ); $ftp = new cFTP_Session(); try { $ftp->connect($ftp_connection); # Login (default as anonymous) $ftp->login(); $root = $ftp->dir(); if( !$root->childExists('foo.txt') ) die("File doesn't exists"); # Create new Chmod helper $chmod = new cFTP_Chmod; $chmod->setEveryoneAccessMode( cFTP_Chmod::READ ); $chmod->setGroupAccessMode( cFTP_Chmod::READ_WRITE ); $chmod->setOwnerAccessMode( cFTP_Chmod::FULL ); $root->file('foo.txt')->changeMode($chmod); # Close the connection $ftp->close(); }
# Include cFTP_Autoloader include '../lib/cFTP/Autoload.php'; # Where to connect $ftp_host = 'ftp.mozilla.org'; # Some set-up $ftp_connection = new cFTP_Connection( $ftp_host ); $ftp = new cFTP_Session($ftp_connection); # Note the diffrent way to connect # Login (default as anonymous) $ftp->login(); $items = $ftp->dir('.')->listAdvanced(); foreach( $items as $item ) { if( $item instanceof cFTP_Directory ) echo 'Directory '; else echo 'File '; echo '<b>'.$item->getName().'</b> found <br/>'; } # Close the connection $ftp->close(); ?>
*/ # Include cFTP_Autoloader include '../lib/cFTP/Autoload.php'; # Where to connect $ftp_host = 'ftp.mozilla.org'; # Some set-up $ftp_connection = new cFTP_Connection( $ftp_host ); $ftp = new cFTP_Session(); # Connect $ftp->connect($ftp_connection); # Login (default as anonymous) $ftp->login(); # Loop items and print 'em $items = $ftp->dir('.')->listItems(); foreach( $items as $item ) { echo "<b>$item</b> found <br/>"; } # Close the connection $ftp->close(); ?>
$ftp_host = 'fttp.mozilla.org'; # Some set-up $ftp_connection = new cFTP_Connection( $ftp_host ); $ftp = new cFTP_Session(); try { $ftp->connect($ftp_connection); # Login (default as anonymous) $ftp->login(); # Following code is avaible only on PHP version > 5.3, # if you want to do same thing on PHP version lower than 5.3 use create_function() $items = $ftp->dir('.')->walk( function( cFTP_Item $e ) { echo '<b>'.$e->getName().'</b> found <br/>'; }); # Close the connection $ftp->close(); } catch( cFTP_Exception $e) { printf('Error #%d: %s', $e->getCode(), $e->getMessage()); } ?>