XXXIIIFTP 関数

導入

この拡張モジュールの関数は、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内部にコンパイルされているか実行時に動的にロー ドされるかのどちらかの場合のみ使用可能です。

FTP_ASCII (integer)

FTP_TEXT (integer)

FTP_BINARY (integer)

FTP_IMAGE (integer)

FTP_TIMEOUT_SEC (integer)

詳細は、ftp_set_option() を参照下さい。

以下の定数は、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)

非同期伝送がまだアクティブです。

例 1FTPの例

<?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); 
?>

目次
ftp_cdup -- 親ディレクトリに移動する
ftp_chdir -- FTP サーバー上でディレクトリを移動する
ftp_close -- FTP接続を閉じる
ftp_connect -- FTP 接続をオープンする
ftp_delete -- ftp サーバー上のファイルを削除する
ftp_exec --  ftpサーバでプログラム実行する
ftp_fget --  FTP サーバーからファイルをダウンロードし、オープン中のファイルに 保存する
ftp_fput --  オープン中のファイルをFTPサーバーにアップロードする
ftp_get_option --  カレントのFTPストリームの種々の実行動作を取得する
ftp_get -- FTPサーバーからファイルをダウンロードする
ftp_login -- FTP 接続でログインする
ftp_mdtm -- 指定したファイルが最後に修正された時間を返す
ftp_mkdir -- ディレクトリを作成する
ftp_nb_continue -- Continues retrieving/sending a file (non-blocking)
ftp_nb_fget -- Retrieves a file from the FTP server and writes it to an open file (non-blocking)
ftp_nb_fput -- Stores a file from an open file to the FTP server (non-blocking)
ftp_nb_get -- Retrieves a file from the FTP server and writes it to a local file (non-blocking)
ftp_nb_put -- Stores a file on the FTP server (non-blocking)
ftp_nlist -- 指定したディレクトリのファイルの一覧を返す
ftp_pasv -- パッシブモードをオンまたはオフにする
ftp_put -- FTP サーバーにファイルをアップロードする
ftp_pwd -- 現在のディレクトリ名を返す
ftp_quit -- FTP接続を閉じる
ftp_rawlist --  指定したディレクトリの詳細なファイル一覧を返す
ftp_rename -- ftp サーバー上のファイルの名前を変更する
ftp_rmdir -- ディレクトリを削除する
ftp_set_option --  FTP実行オプションを設定する
ftp_site -- SITEコマンドをサーバーに送信する
ftp_size -- 指定したファイルのサイズを返す
ftp_ssl_connect -- セキュアな FTP 接続をオープンする
ftp_systype --  リモート FTP サーバーのシステム型IDを返す