Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
ftp_rename() function in PHP
The ftp_rename() function renames a file or directory on the FTP server.
Syntax
ftp_rename(conn,oldname,newname);
Parameters
conn − The FTP connection
old_name − The file or directory to rename.
new_name − The new name of the file or directory
Return
The ftp_rename() function returns TRUE on success or FALSE on failure.
Example
The following is an example −
<?php
$ftp_server = "192.168.0.4";
$ftp_user = "jacob";
$ftp_pass = "tywg61gh";
$conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($con, $ftp_user, $ftp_pass);
$old_file = "demo.txt";
$new_file = "new.txt";
// rename
if (ftp_rename($conn, $old_file, $new_file)) {
echo "Renamed $old_file to $new_file";
} else {
echo "Cannot rename $old_file to $new_file";
}
// close
ftp_close($conn);
?>Advertisements