Solved

PHP5: how to prevent users to download images from my site?

Posted on 2014-07-21
7
213 Views
Last Modified: 2014-07-21
Hello Experts,

What is the best way to prevent users from downloading images from my site?

Regards,
0
Comment
Question by:epifanio67
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40210316
Take your website off the internet.

If you don't want to do that then there is nothing you can do about it.
0
 
LVL 13

Assisted Solution

by:duncanb7
duncanb7 earned 167 total points
ID: 40210330
Could you do it on .htaccess file instead of php so that users can not access image site ?

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]

And the site if let user view the image, in other words, what they view and what they can
download unless don't putting it on servers

Duncan
0
 

Author Comment

by:epifanio67
ID: 40210331
hahahahaha...

ok... I realize it is impossible.....
but is there ways I can 'prevent' the image URLs from being used on other sites via htaccess file?

funny.... and I agree...
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:epifanio67
ID: 40210335
sorry duncan.... I must have posted the comment to Gary seconds after you posted yours..

that's what I was looking for....

thanks..

I will wait a few more min for more suggestions...
0
 
LVL 58

Assisted Solution

by:Gary
Gary earned 166 total points
ID: 40210340
You can prevent hotlinking

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ stolen_from_my_site.jpg [NC,R,L]

edit:
Actually rowby's solution is similar - I'll leave mine since it gives you the option of redirecting to another image that you can make that says Stolen from mysite.com just to piss the other website off. (but Rowby deserves the main credit)
0
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 167 total points
ID: 40210345
You might find this useful. The strategy is to make it impossible for the image to have a direct-to-file URL.
http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/A_10065-Adding-a-Watermark-to-an-Image.html
0
 

Author Closing Comment

by:epifanio67
ID: 40210362
thank you experts... I truly appreciate your help...

Regards,
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question