How to rename file using PHP

To rename a file, you use the rename() function. This function also allows you to move a file to a different directory. For example, to rename the test.txt file to test.bak file, you use the following code. You may also like How to Copy file from one folder to another folder using PHP and How to get file size in PHP.

Code

rename('test.txt','testing.txt');

Leave a Reply

Your email address will not be published. Required fields are marked *