2

The Unlink works perfectly.

if ( file_exists("result/feed/kalo/Cnf.txt" ) && file_exists("result/feed/vor/Cnm.txt")){
        unlink("result/feed/kalo/Cnf.txt");

        if ( ! rename("result/feed/vor/Cnm.txt","result/feed/vor/Cnm1.txt") ) {
            echo 'Não renomeou para Cnm1 !';
        }
    } 

Yet, I keep getting the following error:

Warning: rename(result/feed/vor/Cnm.txt,result/feed/vor/Cnm1.txt) [function.rename]: No error in C:\wamp2\www\beed\loof.php on line 57 Não renomeou para Cnm1 !

1 Answers1

0

"I tried giving an unlink but gave permission denied – Ricardo Schieck 33 secs ago "

You need to assign proper permissions to folders and files in order to be modified.

References:

Your path assignments may also be off, and you may need to go from the server's root.

I.e.: (you will need to use the actual path from your server)

/var/user/public/result/feed/kalo/Cnf.txt

and applying that logic to all your other assignments.

Plus, you may need to change your && operator to an || being "OR" rather than && being "AND".

Use error reporting:

and make sure that the file (or files) to be renamed exist.

Community
  • 1
  • 1
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
  • I try to put all the necessary permissions , but not works ... The error reporting say to me the same thing , permission denied... – Ricardo Schieck Mar 14 '17 at 18:53
  • @RicardoSchieck It's definitely a permissions issue and I've included a few links about this and how to do it, depending on the OS you're using. – Funk Forty Niner Mar 14 '17 at 18:54
  • Yes ! I try to do it with the windows link , but doesn't works.. I try the chmod and the chown , but the chown doesn't set ... – Ricardo Schieck Mar 14 '17 at 18:58
  • I was do changes my operator and make 'if the file exist' , and the file exist... – Ricardo Schieck Mar 14 '17 at 19:01
  • `if ( file_exists("result/feed/kalo/Cnf.txt" ) && file_exists("result/feed/vor/Cnm.txt"))` - both files must exist with the `&&` operator which means "AND". If one of those does not exist, you need to use the `||` operator which means "OR" - `if ( file_exists("result/feed/kalo/Cnf.txt" ) || file_exists("result/feed/vor/Cnm.txt"))` @RicardoSchieck – Funk Forty Niner Mar 14 '17 at 19:03
  • @RicardoSchieck also `if ( ! rename("result/feed/vor/Cnm.txt"` that must also exist in order for it to be renamed and using a path example I shown as an example in my answer. – Funk Forty Niner Mar 14 '17 at 19:05