PHP code example of xp-framework / ftp
1. Go to this page and download the library: Download xp-framework/ftp library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
xp-framework / ftp example snippets
use peer\ftp\{FtpConnection, FtpTransfer};
use io\File;
$c= (new FtpConnection('ftp://user:[email protected]/'))->connect();
// Upload logo.png to the connection's root directory
$c->rootDir()->file('logo.png')->uploadFrom(new File('logo.png'));
// Upload from a stream using ASCII mode
$c->rootDir()->file('README.md')->uploadFrom(
new MemoryInputStream('Read me first!'),
FtpTransfer::ASCII
);
$c->close();
use peer\ftp\FtpConnection;
$c= (new FtpConnection('ftp://user:[email protected]/'))->connect();
// List root directory's contents
foreach ($c->rootDir()->entries() as $entry) {
Console::writeLine('- ', $entry);
}
$c->close();