Rename an uploaded file with PHP but keep the extension

后端 未结 7 1347
悲&欢浪女
悲&欢浪女 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:03

    this code is insecure

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

    if

    $_POST[firstname] =mypicture.php%00
    

    and

    $extension=.jpg;
    

    this code is vulnerable and result is

    test.php%00.jpg //test.php uploaded on server.
    

    for more information check this link:

    https://www.owasp.org/index.php/Unrestricted_File_Upload

提交回复
热议问题