Solved

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

Posted on 2014-07-21
7
212 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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 109

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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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 HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to create an extensible mechanism for linked drop downs.
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

830 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