File Rename() Function

In the php rename() function is used to rename a files or directory in the server and which is returns two results that are TRUE and FALSE .if TRUE results is a success and FALSE results is a failure.

Demo :




Example :

Just type new file name at New File Name text box field and then click change button and now will be changed in the above old file name.

Code :

Following code is use to rename file from old .txt file if you need code to copy and use to your website.


  <?php
  $oldFile = "";
  $new_file_name = "";
  if (file_exists($oldFile))
  {
    rename ($oldFile, $new_file_name) or die("Cannot move/rename file '$oldFile'");
  }
  ?>

In the above file_exists() function is use to check file available on server and rename () function is used to re name a old file name to new file name but will not change inside content.

Free Download Script :

If you need rename() function click and download from following link.

Download




Content