dev-master
9999999-devFTPClient for PHP
MIT
The Requires
- php >=5.3.0
- ext-ftp *
php client class ftp ftpclient
0.0.1
0.0.1.0FTPClient for PHP
MIT
The Requires
- php >=5.3.0
- ext-ftp *
php client class ftp ftpclient
FTPClient for PHP
By Egor Talantsev. (http://www.ananas-web.ru/), (*1)
licensed under the MIT licenses, (*2)
Connection to FTP Host :, (*3)
$ftp = new FTPClient(); $ftp->connect($host, $ssl, $port, $timeout); $ftp->login($username, $password);
// This uses passive mode $ftp->passive(); // If you want to disable using passive mode then $ftp->passive(false);
// This uses binary mode, required for downloading binaries like zip $ftp->binary(true); // standard is false
// 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');
$ftp->changeDirectory('/root_dir/sub_dir'); $ftp->parentDirectory(); // now we are in /root_dir
// will return current path as string $ftp->getDirectory();
// creates a directory in current path $ftp->createDirectory($directoryName);
$ftp->removeDirectory($directoryName);
// returns directory list as array $ftp->listDirectory();
// executes the FTP LIST command, and returns the result as an array $ftp->rawlistDirectory($parameters, $recursive);
$ftp->delete($filename);
$ftp->size($filename);
// returns unix timestamp $ftp->modifiedTime($filename); // returns formated $ftp->modifiedTime($filename, $format);
$ftp->rename($current, $new);
// Downloads a file from remote host $ftp->get($localFile, $remoteFile); // Downloads file to an open file $ftp->fget($handle, $remoteFile);
// Uploading local file to remote host $ftp->put($remoteFile, $localFile); // Uploading from an open file $ftp->fput($remoteFile, $handle);
$ftp->getOption(FTPClient::TIMEOUT_SEC);
$ftp->setOption(FTPClient::TIMEOUT_SEC, 30);
$ftp->allocate($filesize);
$ftp->chmod($mode, $filename);
$ftp->exec($command);
Class throws exception if opetarion fails. So simply use try-catch blocks., (*4)
try { $ftp = new FTPClient(); $ftp->connect($host, $ssl, $port, $timeout); $ftp->loginlogin($username, $password); } catch (Exception $e) { // we got the error! }
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., (*5)
Special thanks to Melih Ucar for his package that was used as base for this packeje, (*6)
FTPClient for PHP
MIT
php client class ftp ftpclient
FTPClient for PHP
MIT
php client class ftp ftpclient