How to avoid UNLINK security risks in PHP?

后端 未结 7 1075
深忆病人
深忆病人 2021-01-12 18:59

I\'m using UNLINK with PHP and AJAX. I know that in this way is very dangerous, because everyone can delete any files. But I need to use AJAX

7条回答
  •  无人共我
    2021-01-12 19:43

    Limit the unlinking to the directory with the photos. That is, do not allow .. in the path, or check the full path after doing realpath(). Otherwise, the user can request delete_photo.php?photo_id=../../../../etc/passwd and break the system.

提交回复
热议问题