PHP ftp_rename() Function

Definition and Usage

The ftp_rename() function changes the file or directory name on the FTP server.

If successful, returns true; otherwise, returns false.

Syntax

ftp_rename(ftp_connection,from,to)
Parameter Description
ftp_connection Required. Specifies the FTP connection to use (the identifier for the FTP connection).
from Required. Specifies the file or directory to be renamed.
to Required. Specifies the new name for the file or directory.

Example

<?php
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");
ftp_rename($conn,"oldname.txt","newname.txt");
ftp_close($conn);
?>