Restricting Access To Images

Discussion in 'Programming' started by TechMaster, Mar 30, 2009.

  1. #1
    Hello,

    I am developing a site for a client which is related to photography. My client doesn't want the images on the site to be accessed by anyone except its own site i.e a person can view the image when opens website but can't see image when type entire url of the image in browser.

    Any solution? any asp or php script?

    I have protected site from hotlinking.

    Thank you
     
    TechMaster, Mar 30, 2009 IP
  2. technomassage

    technomassage Peon

    Messages:
    48
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You should use javascript to protect images. you can disable right click
     
    technomassage, Mar 30, 2009 IP
  3. plog

    plog Peon

    Messages:
    298
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #3
    You might look into .htaccess, although I am not exactly certain where to direct you.

    As for .php I do know you could put a sort of wrapper around your images. What you would do is make the source of any image something like src="http://www.example.com/images.php?image=7". Then you have a .php file that checks to make sure the requesting page is a valid page, finds that image requested and returns it. If they try to directly browse to that image you send them a picture that says 'Invalid Request' on it.

    For this, look at the header function in php.
     
    plog, Mar 30, 2009 IP
  4. mmerlinn

    mmerlinn Prominent Member

    Messages:
    3,197
    Likes Received:
    819
    Best Answers:
    7
    Trophy Points:
    320
    #4
    You can make it hard for someone to access the images, but you cannot totally stop them.

    By definition, to view the images, they MUST BE DOWNLOADED TO THE VIEWER'S COMPUTER. Once the images are on his computer, YOU TOTALLY LOSE CONTROL OVER THEM.

    The ONLY GUARANTEED solution is to NEVER put the pictures on the website.
     
    mmerlinn, Mar 31, 2009 IP
  5. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Disabling right-click will just make it slightly harder to download the images... The best thing would probably be to watermark the images, and only use thumbnails. Because no matter what you do, if the image is being displayed a simple Print-Screen (take a screenshot) can be used to get the image regardless.
     
    camjohnson95, Mar 31, 2009 IP
  6. mrhrk01

    mrhrk01 Well-Known Member

    Messages:
    664
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    145
    #6
    Disabling right will make a difference ot the newbies but people who want to get things find creative ways to getting them. I would suggest:
    1) Water mark the photographs/images
    2) Place a blank transparent image over all images so when someone right clicks and saves they will save a blank file.
    3) Another idea you can use is to use javascript or even CSS, so when some one hovers over the image it changes to another image(such as a fixed company name image- which the user will NOT want to save)

    But it is extremely difficult to hide your images online, even if you undertake the above mentioned ideas(from myself and others)
     
    mrhrk01, Mar 31, 2009 IP
  7. eamiro

    eamiro Well-Known Member

    Messages:
    274
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    123
    #7
    You can disable hotlinking in .htaccess file, but it won't prevent saving the image on any computer, then hosting it elsewhere.

    You can try to create a PHP file, example getfile.php and use readfile(); function so the real image link won't be displayed, but this won't prevent taking a screenshot and croping it!
     
    eamiro, Mar 31, 2009 IP