title: PHP: move with rename fails, but combination of copy and unlink works
body: <p>I am trying to use PHP's <code>rename</code> to move a file to a different folder (and also rename the file in the same step). However, <code>rename</code> always returns <code>false</code>. On the other hand, using a combination of <code>copy</code> and <code>unlink</code> works just fine. What could be causing this?</p>
  
  <p>The relevant code looks like this:</p>
  
  <pre><code>  if (!rename($targetpath, $backuppath)) {
      // if rename fails, try with copy and delete
      if (!copy($targetpath, $backuppath)) 
        die("9\nCould not move existing file to backup");
      touch($backuppath, filemtime($targetpath));
      if (!unlink($targetpath))
        die("9\nCould not move existing file to backup");
    }
  </code></pre>
  
  <p>The paths would be e.g.</p>
  
  <pre><code>$targetpath: /path/to/plots/some.pdf
  $backuppath: /path/to/plots/old/some.pdfX14068815860
  </code></pre>