この拡張モジュールの関数は、http://www.faqs.org/rfcs/rfc959.htmlで定義された File Transfer
Protocol (FTP)を使用してファイルサーバにアクセスするクライアントの
実装です。
これらの関数は、標準モジュールの一部として利用可能であり、常に使用できます。
PHPでFTP関数を使用するには、PHP 4をインストール際には
--enable-ftpオプション、PHP 3を使
用する場合には--with-ftpを追加する
必要があります。
Windows版のPHPには
この拡張モジュールのサポートが組み込まれています。これらの関数を使用
するために拡張モジュールを追加でロードする必要はありません。
この拡張モジュールは設定ディレクティブを全く定義しません。
この拡張モジュールは、1種類のリソース型を使用します。このリソース
型は、FTP接続のリソースIDで、ftp_connect()によ
り返されたものです。
これらの定数は、この拡張モジュールで定義されており、
この拡張モジュールがPHP内部にコンパイルされているか実行時に動的にロー
ドされるかのどちらかの場合のみ使用可能です。
以下の定数は、PHP 4.3.0で追加されました。
- FTP_AUTOSEEK
(integer)
詳細は、ftp_set_option() を参照して下さい。
- FTP_AUTORESUME
(integer)
GETおよびPUTリクエスト用のレジューム位置と開始位置を自動的に定義
します。(FTP_AUTOSEEKが有効な場合のみ動作します。)
- FTP_FAILED
(integer)
非同期伝送が失敗しました。
- FTP_FINISHED
(integer)
非同期伝送が終了しました。
- FTP_MOREDATA
(integer)
非同期伝送がまだアクティブです。
例 1. FTPの例
<?php // set up basic connection $conn_id = ftp_connect($ftp_server);
// login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection if ((!$conn_id) || (!$login_result)) { echo "Ftp connection has failed!"; echo "Attempted to connect to $ftp_server for user $ftp_user_name"; die; } else { echo "Connected to $ftp_server, for user $ftp_user_name"; }
// upload the file $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
// check upload status if (!$upload) { echo "Ftp upload has failed!"; } else { echo "Uploaded $source_file to $ftp_server as $destination_file"; }
// close the FTP stream ftp_close($conn_id); ?>
|
|