Rename an uploaded file with PHP but keep the extension

后端 未结 7 1335
悲&欢浪女
悲&欢浪女 2020-12-04 20:24

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_upl         


        
相关标签:
7条回答
  • 2020-12-04 21:09
    move_uploaded_file($_FILES["picture"]["tmp_name"], "peopleimages/" . "$_POST[lastname]" . '_' . "$_POST[firstname]." . pathinfo($_FILES["picture"]["tmp_name"], PATHINFO_EXTENSION));
    
    0 讨论(0)
提交回复
热议问题