Breaking News
Home / Web / PHP / PHP Snippets / How to rename file in PHP?

How to rename file in PHP?

If you want to rename a file in PHP you can use the rename function. The syntax of the rename function is same as that of the UNIX mv(move) command. The general syntax is:

rename(‘/pathA/old_file_name’, ‘/pathB/new_file_name’);


rename(‘/tmp/data.log’, ‘/tmp/data1.log’);


Check Also

How to list files in a directory in PHP?

<?php if ($handle = opendir(‘/path/to/directory’)) {     echo "Directory handle: $handlen";     echo …

Advertisment ad adsense adlogger