How to protect against direct access to images?

前端 未结 9 1039
没有蜡笔的小新
没有蜡笔的小新 2020-12-05 00:47

I would like to create a web site with many images. But I would like to protect against direct access to images, e.g. direct links to images without visiting the web site.

9条回答
  •  -上瘾入骨i
    2020-12-05 01:19

    You could use a PHP script to retrieve the images using something like:

    and have the PHP script return the image data only after confirming that the domain of the HTTP_REFERER is your's.

    If you have an account-oriented site, I suggest using PHP sessions as you stated and have the PHP script verify the session before returning the image data.

提交回复
热议问题