2017 © Pedro Peláez
 

library ftpclient

FTPClient for PHP

image

melihucar/ftpclient

FTPClient for PHP

  • Monday, July 6, 2015
  • by melihucar
  • Repository
  • 4 Watchers
  • 27 Stars
  • 89,968 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 16 Forks
  • 1 Open issues
  • 5 Versions
  • 7 % Grown

The README.md

FTP Client for PHP

Build Status Total Downloads Latest Stable Version, (*1)

Support via Gittip, (*2)

By Melih Ucar. (http://www.melihucar.net/), (*3)

licensed under the MIT licenses, (*4)

USAGE

Connection to FTP Host :, (*5)

$ftp = new FTPClient();
$ftp->connect($host, $ssl, $port, $timeout);
$ftp->login($username, $password);

Using Passive Mode :

// This uses passive mode
$ftp->passive();

// If you want to disable using passive mode then
$ftp->passive(false);

Using Binary Mode :

// This uses binary mode, required for downloading binaries like zip
$ftp->binary(true);

// standard is false

Changing Directory :

// You can use fullpath to change dir
$ftp->changeDirectory('/root_dir/sub_dir');

// or you can use method chaining
$ftp->changeDirectory('/root_dir')->changeDirectory('sub_dir');

Change To Parent Directory :

$ftp->changeDirectory('/root_dir/sub_dir');

$ftp->parentDirectory(); // now we are in /root_dir

Getting Current Directory :

// will return current path as string
$ftp->getDirectory();

Creating Directory :

// creates a directory in current path
$ftp->createDirectory($directoryName);

Removing Directory :

$ftp->removeDirectory($directoryName);

Getting Directory List :

// returns directory list as array
$ftp->listDirectory();

Getting Directory List :

// executes the FTP LIST command, and returns the result as an array
$ftp->rawlistDirectory($parameters, $recursive);

Deleting File :

$ftp->delete($filename);

Returns file size (bytes) :

$ftp->size($filename);

Returns last modified time :

// returns unix timestamp
$ftp->modifiedTime($filename);

// returns formated
$ftp->modifiedTime($filename, $format);

Renaming files or folders :

$ftp->rename($current, $new);

Downloading a file :

// Downloads a file from remote host
$ftp->get($localFile, $remoteFile);

// Downloads file to an open file
$ftp->fget($handle, $remoteFile);

Uploading a file :

// Uploading local file to remote host
$ftp->put($remoteFile, $localFile);

// Uploading from an open file
$ftp->fput($remoteFile, $handle);

Getting server options :

$ftp->getOption(FTPClient::TIMEOUT_SEC);

Setting server options :

$ftp->setOption(FTPClient::TIMEOUT_SEC, 30);

Allocating space for uploading file :

$ftp->allocate($filesize);

Changing file and directory permissions :

$ftp->chmod($mode, $filename);

Running custom command on remote server :

$ftp->exec($command);

Error Handling :

Class throws exception if opetarion fails. So simply use try-catch blocks., (*6)

try {
    $ftp = new FTPClient();
    $ftp->connect($host, $ssl, $port, $timeout);
    $ftp->loginlogin($username, $password);
} catch (Exception $e) {
    // we got the error!
}

Contributing

Did you find a bug or do you know a better way to do it? Simply just fork and fix it. Then send a pull request., (*7)

The Versions

06/07 2015

dev-master

9999999-dev

FTPClient for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-ftp *

 

php client class ftp ftpclient

29/09 2014

1.3.x-dev

1.3.9999999.9999999-dev

FTPClient for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-ftp *

 

php client class ftp ftpclient

21/06 2014

1.1.x-dev

1.1.9999999.9999999-dev

FTPClient for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-ftp *

 

php client class ftp ftpclient

21/06 2014

1.2.x-dev

1.2.9999999.9999999-dev

FTPClient for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-ftp *

 

php client class ftp ftpclient

27/11 2013

1.0

1.0.0.0

FTPClient for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-ftp *

 

php client class ftp ftpclient