php
PHP - FTP로 파일이름 변경하기
다음은 파일 이름을 변경하는 예제입니다. 원격을 지원합니다.
<?php
// ftp는 상대경로, 절대경로가 허용되지 않으며,
// 보통 public_html, www, html 로 시작합니다.
// 호스트 정보
$ftp_server = "호스트 혹은 ip주소";
$ftp_user_name = "접속 아이디";
$ftp_user_pass = "접속 패스워드";
// 호스트 접속
$conn_id = ftp_connect($ftp_server);
// 호스트 로그인
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
$old_file = 'somefile.txt.bak';
$new_file = 'somefile.txt';
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);
?>
0 댓글