Simple OOP FTP library
这个扩展是对常用ftp函数的面向对象封装。
protected/extensionsThe following code is the component registration in the config file:
'components'=>array( 'ftp'=>array( 'class'=>'application.extensions.ftp.EFtpComponent', 'host'=>'127.0.0.1', 'port'=>21, 'username'=>'yourusername', 'password'=>'yourpassword', 'ssl'=>false, 'timeout'=>90, 'autoConnect'=>true, ),... )
See the following code example:
$ftp = Yii::app()->ftp; $ftp->put('remote.txt', 'D:\local.txt'); $ftp->rmdir('exampledir'); $ftp->chdir('aaa'); $ftp->currentDir(); $ftp->delete('remote.txt');
Total 4 comments
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.
The problem, that the program dies at the ftp_mkdir line. I get the php error:
I cant error handle, becouse the program execution stops!
Enclode code in try catch block and check what value returns ftp_mkdir command - if it is zero throw exception.
Hi!
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?
Thanks!
Leave a comment
Please login to leave your comment.