Sanitize file path in PHP

后端 未结 7 1079
夕颜
夕颜 2020-12-01 11:00

Greetings, I\'m hoping to make my tiny program secure so that potential malicious users cannot view sensitive files on the server.

    $path = \"/home/gsmcm         


        
7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 11:18

    realpath() will let you convert any path that may contain relative information into an absolute path...you can then ensure that path is under a certain subdirectory that you want to allow downloads from.

提交回复
热议问题