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ã‚’è¿”ã™