PHP code example of hguenot / yii2-gftp
1. Go to this page and download the library: Download hguenot/yii2-gftp 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/ */
hguenot / yii2-gftp example snippets
return [
// [...]
'components'=>[
// [...]
'ftp' => [
'connectionString' => 'ftp://user:pass@host:21',
'driverOptions' => [
'timeout' => 120,
'passive' => false
]
]
],
// [...]
];
return [
// [...]
'components'=>[
// [...]
'ftp' => [
'class' => '\gftp\FtpComponent',
'driverOptions' => [
'class' => '\gftp\drivers\SftpProtocol',
'user' => '[email protected] ',
'pass' => 'PassW0rd',
'host' => 'ftp.somewhere.otrb',
'port' => 2121,
'timeout' => 120,
'passive' => false
]
]
],
// [...]
];
$files = $gftp->ls();
$gftp->chdir('images');
public function actionExample() {
$remote_file = '/data/users.txt';
$local_file = '/tmp/users.load';
$mode = 'FTP_ASCII';
$asynchronous = false;
$file = Yii::$app->ftp->get($remote_file, $local_file, $mode, $asynchronous);
// [...]
}
use gftp\FtpWidget;
echo FtpWidget::widget();
use \gftp\FtpWidget;
echo FtpWidget::widget([
'ftp' => \Yii::$app->get('otrb')
]);
use \gftp\FtpWidget;
use \gftp\FtpComponent;
echo FtpWidget::widget([
'ftp' => new FtpComponent([
'driverOptions' => [
'class' => '\gftp\drivers\SftpProtocol',
'user' => '[email protected] ',
'pass' => 'PassW0rd',
'host' => 'ftp.somewhere.otrb',
'port' => 2121,
'timeout' => 120,
'passive' => false
]
]);
]);
php composer.phar