Google

NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7">

XXXIIIFTP 関数

この拡張モジュールの関数は、http://www.faqs.org/rfcs/rfc959.htmlで定義された File Transfer Protocol (FTP)を使用してファイルサーバにアクセスするクライアントの 実装です。

FTP モジュールを使用する際、次の定数が定義されます。 FTP_ASCIIおよびFTP_BINARY

PHPの設定でFTP関数を使用するためには、PHP 4をインストールする場合、 オプション --enable-ftp、PHP 3を使用している場合には、 --with-ftpを使用する必要があります。

例 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_systype --  リモート FTP サーバーのシステム型IDを返す