title: How to update/replace php script on server
body: <p>I am working on update feature for a CMS. But I stuck on this. The scenario is user will able to upload a zip file, the updater script will extract it and replace the old one.</p>
  
  <p>I have a problem with replacing, I've done the following</p>
  
  <pre><code>&lt;?php rename($old, $new);
  </code></pre>
  
  <p>I always get "Permission Denied"</p>
  
  <p>using <code>ftp_rename</code>:</p>
  
  <pre><code>&lt;?php
  $conn = ftp_connect($host);
  ftp_login($conn, 'user', 'pass');
  ftp_rename($conn, $src, $dest);
  </code></pre>
  
  <p>I always get </p>
  
  <blockquote>
    <p>Warning: ftp_rename(): Rename Failed. on....</p>
  </blockquote>
  
  <p>Is there a proper way to do this ? thanks.</p>
  
  <hr>