Search code examples
phpauthenticationrenamelamp

Renaming a file on log out


I'm trying to rename a file with PHP but for some reason it doesnt work, do I have to activate some special permissions under PHP?

heres my code for the php file

<?php
  if(!rename('file.php','filer.php'))
  {
    echo "Couldn't rename file!";
  }
  else 
  {
    echo "file renamed succesfully!";
  }
?>

I'm trying to rename a file on my /var/www directory when they sign out of a login area, so that way they cant access back hitting back button. Do I have an error on my code? Or is there another way to prevent this?


Solution

  • The Default permissions on this folder /var/www/ are: chmod 755 /var/www/

    "read, write, and execute by owner" and "read and execute by the group and everyone else" (-rwxr-xr-x)

    and the files inside the folder /var/www/file are: chmod 644 /var/www/file

    I don't know if you have changed the Permissions or simply execute this command and it we'll work.

    chmod 777 /var/www/file.php

    "read, write, and execute by owner, group and everyone else"