Solved

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

Posted on 2014-07-21
7
209 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
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 tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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 …

867 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

15 Experts available now in Live!

Get 1:1 Help Now