FTP ftp_rename

(PHP 4, PHP 5, PHP 7, PHP 8)

ftp_rename — FTP 서버의 파일 또는 디렉토리 이름을 바꿉니다.


설명

ftp_rename(FTP\Connection $ftp, string $from, string $to): bool

ftp_rename()은 FTP 서버에서 파일이나 디렉토리의 이름을 바꿉니다.


매개변수

ftp
FTP\Connection 인스턴스입니다.
from
이전 파일/디렉토리 이름입니다.
to
새 이름입니다.

반환 값

성공하면 true를, 실패하면 false를 반환합니다. 실패 시(예: 존재하지 않는 파일의 이름을 바꾸려는 시도) E_WARNING 오류가 발생합니다.


변경 로그

버전 설명
8.1.0 ftp 매개변수는 이제 FTP\Connection 인스턴스를 필요로 합니다. 이전에는 리소스가 필요했습니다.

Examples

예제 #1 ftp_rename() 예제

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

// set up basic connection
$ftp = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);

// try to rename $old_file to $new_file
if (ftp_rename($ftp, $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";
}

// close the connection
ftp_close($ftp);
?>