1<?php rename ("/folder/file.ext", "newfile.ext"); ?>
2
3The above doesn't rename the file within the folder, as you might assume,
4instead, it moves the file to whatever the PHP working directory is...
5Chances are you'll not find it in your FTP tree.
6Instead, use the following:
7
8<?php rename ("/folder/file.ext", "/folder/newfile.ext"); ?>
1<?php
2
3$oldname = 'readme.txt';
4$newname = 'readme_v2.txt';
5
6if (rename($oldname, $newname)) {
7 $message = sprintf(
8 'The file %s was renamed to %s successfully!',
9 $oldname,
10 $newname
11 );
12} else {
13 $message = sprintf(
14 'There was an error renaming file %s',
15 $oldname
16 );
17}
18
19echo $message;
20Code language: HTML, XML (xml)