Rename an uploaded file with PHP but keep the extension

Posted by paracaudex on Stack Overflow See other posts from Stack Overflow or by paracaudex
Published on 2010-04-01T18:55:29Z Indexed on 2010/04/01 19:03 UTC
Read the original article Hit count: 240

Filed under:
|

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:

move_uploaded_file($_FILES["picture"]["tmp_name"], "peopleimages/" . "$_POST[lastname]" . '_' . "$_POST[firstname]")

which, of course, renames the file lastname_firstname without an extension. How do I rename the file but keep the extension?

Thanks!

© Stack Overflow or respective owner

Related posts about fileupload

Related posts about php