title: Rename an uploaded file with PHP but keep the extension
body: <p>I'm using PHP to upload an image from a form to the server and want to rename the image lastname_firstname.[original extension].  I currently have:</p>
  
  <pre><code>move_uploaded_file($_FILES["picture"]["tmp_name"], "peopleimages/" . "$_POST[lastname]" . '&amp;#95;' . "$_POST[firstname]")
  </code></pre>
  
  <p>which, of course, renames the file lastname_firstname without an extension. How do I rename the file but keep the extension?</p>
  
  <p>Thanks!</p>