Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. PHP Image Protection

PHP Image Protection

Scheduled Pinned Locked Moved Web Development
phphtmldatabasetutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hxhl95
    wrote on last edited by
    #1

    Hiya everyone, So yes, as the title states, I'm trying to protect images on a website from being downloaded directly (privacy problems). What I've done (or am trying to do) is something like <a href='img.php?file=blah.jpg'>. However, in img.php, I don't know how to tell if the image is being requested in the actual page (index.html, lets say) with the <a> tag, or if it's requested seperately by someone who's copied that url and viewed it (in a different window, maybe). I've tried $_SERVER['REQUEST_URI'] but that returns img.php?file=blah.jpg under both circumstances. Is there any way I can find out? Thanks in advance. :)

    G 1 Reply Last reply
    0
    • H hxhl95

      Hiya everyone, So yes, as the title states, I'm trying to protect images on a website from being downloaded directly (privacy problems). What I've done (or am trying to do) is something like <a href='img.php?file=blah.jpg'>. However, in img.php, I don't know how to tell if the image is being requested in the actual page (index.html, lets say) with the <a> tag, or if it's requested seperately by someone who's copied that url and viewed it (in a different window, maybe). I've tried $_SERVER['REQUEST_URI'] but that returns img.php?file=blah.jpg under both circumstances. Is there any way I can find out? Thanks in advance. :)

      G Offline
      G Offline
      Graham Breach
      wrote on last edited by
      #2

      You could check $_SERVER['HTTP_REFERER'] - that should give you the URI of the page that referred to the image, as long as the user's browser doesn't have referrer sending switched off.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups