Restrict access to images on my website except through my own htmls

前端 未结 5 348
没有蜡笔的小新
没有蜡笔的小新 2021-01-03 14:33

On my website I store user pictures in a simple manner such as: \"image/user_1.jpg\".

I don\'t want visitors to be able to view images on my server just by trying us

5条回答
  •  孤街浪徒
    2021-01-03 15:25

    As has been said hotlinking protection does not protect your files from listing just by altering their id. Plus Refferer can be easily faked.

    In this case I would recommend some kind of authentication. You must create PHP script that will serve images only if it verify logged user via COOKIES or SESSION. (I wouldn't recommend using md5 of user password).

    Maybe you'll need some SQL table to save access permissions.

    Oh and to protect your images you can just place .htaccess with

    deny from all
    

    to the images folder.

提交回复
热议问题