Solved

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

Posted on 2014-07-21
7
208 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
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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 108

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now