Like the PHP solution,
this method relies on the HTTP_REFERER variable (the variable that contains information
about the referring page) being properly sent by the visitor's browser. A number of
modern browsers as well as some of the anonymous surfing proxies and firewalls allow the user
to change this header. These browsers or proxies will thus either transmit HTTP_REFERER headers
that have some user-specified value or not bother to transmit them at all. There are
also buggy browsers around that unpredictably transmit the wrong HTTP_REFERER
header on occasion.
When this occurs your visitor will either not view the image even when he is on
your site (which means that your own page will have broken link images), or he
may be able to view your images even when it is displayed on the copyright
infringing thief's site.
Hopefully the percentage of people who encounter this is small, but you have to
be aware that these situations do occur.