Yii 1.1: ftp

OOP FTP library

Simple OOP FTP library





  • Yii 1.0 or above


  • Extract ftp folder under protected/extensions


The following code is the component registration in the config file:


See the following code example:

$ftp = Yii::app()->ftp;
$ftp->put('remote.txt', 'D:\local.txt');

Change Log

February 25, 2009

  • Rename CFtpComponent to EFtpComponent

February 25, 2009

  • Initial release.

Total 5 comments

#19407 report it
Pierre84 at 2015/06/22 04:34am
Passive mode ?

Useful and easy to use but your forget the param for passive mode

It seems to be useful to add it in the constructor

ftp_pasv($this->_connection, $this->pasv);

#10831 report it
pmaselkowski at 2012/11/26 02:07pm
Error handling

It's because the way Yii handles warnings. These warnings are generated by php ftp functions, not EFtpComponent. To avoid it either disable warnings in php error handler:


or edit EFtpComponent and put @ before all ftp_* function calls.

#4103 report it
Dzsonny at 2011/06/06 02:43am
Error handling2

The problem, that the program dies at the ftp_mkdir line. I get the php error:

ftp_mkdir() [<a href='function.ftp-mkdir'>function.ftp-mkdir</a>]: Directory already exists

I cant error handle, becouse the program execution stops!

#4102 report it
gawronzo at 2011/06/06 02:27am

Enclode code in try catch block and check what value returns ftp_mkdir command - if it is zero throw exception.

if ( ! ftp_mkdir(...) )
                        throw new CException('Error info ...', 404);
#4100 report it
Dzsonny at 2011/06/06 02:15am
Error handling


The extension is very straightforward, and easy to use. I am having trouble with errorhandling though. If i perform an illegal command. (for example mkdir directory already exists) the program dies with a php error. If i put the command in a try catch structure i get the same result.

As far as i now, the ftp_mkdir command is not soppoused to couse php error, but return a 0 if the transaction wasnt succesfull.

What am i doing wrong? Has somebody got a solution?


Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: miles
  • Category: Networking
  • Votes: +9
  • Downloaded: 2,199 times
  • Created on: Feb 25, 2009
  • Last updated: Oct 18, 2010
  • Tags: ftp