PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, March 15, 2022

[FIXED] Renaming a file on log out

 March 15, 2022     lamp, login, php, rename     No comments   

Issue

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"



Answered By - Alaeddine
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing