php实现ftp易可以吗,FTP for PHP是一个用来访问FTP服务器非常小和易于使用的PHP库...

FTP for PHP

68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f64672f6674702d7068702e73766768747470733a2f2f706f7365722e707567782e6f72672f64672f6674702d7068702f762f737461626c6568747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4e65772532304253442d626c75652e737667

FTP for PHP is a very small and easy-to-use library for accessing FTP servers.

It requires PHP 5.0 or newer and is licensed under the New BSD License. You can obtain the latest version from our GitHub repository or install it via Composer:

php composer.phar require dg/ftp-php

Usage

Opens an FTP connection to the specified host:

$ftp = new Ftp;

$ftp->connect($host);

Login with username and password

$ftp->login($username, $password);

Upload the file

$ftp->put($destination_file, $source_file, FTP_BINARY);

Close the FTP stream

$ftp->close();

// or simply unset($ftp);

Ftp throws exception if operation failed. So you can simply do following:

try {

$ftp = new Ftp;

$ftp->connect($host);

$ftp->login($username, $password);

$ftp->put($destination_file, $source_file, FTP_BINARY);

} catch (FtpException $e) {

echo 'Error: ', $e->getMessage();

}

On the other hand, if you'd like the possible exception quietly catch, call methods with the prefix 'try':

$ftp->tryDelete($destination_file);

When the connection is accidentally interrupted, you can re-establish it using method $ftp->reconnect().

(c) David Grudl, 2008, 2014 (http://davidgrudl.com)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值