title: PHP - Move a file into a different folder on the server
body: <p>I need to allow users on my website to delete their images off the server after they have uploaded them if they no longer want them. I was previously using the <code>unlink</code> function in PHP but have since been told that this can be quite risky and a security issue. (Previous code below:)</p>
  
  <pre><code>if(unlink($path.'image1.jpg')){ 
       // deleted
  }
  </code></pre>
  
  <p>Instead i now want to simply move the file into a different folder. This must be able to be done a long time after they have first uploaded the file so any time they log into their account. If i have the main folder which stores the users image(s):</p>
  
  <pre><code>user/
  </code></pre>
  
  <p>and then within that a folder called del which is the destination to put their unwanted images:</p>
  
  <pre><code>user/del/
  </code></pre>
  
  <p>Is there a command to move a file into a different folder? So that say:</p>
  
  <pre><code>user/image1.jpg
  </code></pre>
  
  <p>moves to/becomes</p>
  
  <pre><code>user/del/image1.jpg
  </code></pre>