FTP 関数
PHP Manual

ftp_rename

(PHP 4, PHP 5, PHP 7)

ftp_rename — FTP サーバー上のファイルまたはディレクトリの名前を変更する

説明

bool ftp_rename ( resource $ftp_stream , string $oldname , string $newname )

ftp_rename() は FTP サーバー上のファイルやディレクトリの 名前を変更します。

パラメータ

ftp_stream

FTP 接続のリンク ID 。

oldname

現在のファイル/ディレクトリの名前。

newname

新しい名前。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。

例

例1 ftp_rename() の例

<?php
$old_file 
= 'somefile.txt.bak';
$new_file = 'somefile.txt';

// 接続を確立する
$conn_id = ftp_connect($ftp_server);

// ユーザー名とパスワードでログインする
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// $old_file を $new_file に変更することを試みる
if (ftp_rename($conn_id, $old_file, $new_file)) {
 echo 
"successfully renamed $old_file to $new_file\n";
} else {
 echo 
"There was a problem while renaming $old_file to $new_file\n";
}

// 接続を閉じる
ftp_close($conn_id);
?>


FTP 関数
PHP Manual