Welcome Guest!
Please login
If you do not have an account yet on The Web Squeeze forums, please Register! It’s FREE and there are many benefits:
- Receive Fast Advice
- Learn Programming Languages
- Get Professional Website Reviews
- Quick Troubleshooting Assistance
|
|
Help With Password Protecting Images Per Customer....
This is a discussion on Help With Password Protecting Images Per Customer...., within the Beginners' Questions section. This forum and the thread "Help With Password Protecting Images Per Customer...." are both part of the Designing Your Website category.
![]() ![]() |
Mar 20 2008, 11:29 AM
Post
#1
|
|
![]() Rapid Squeezer ![]() ![]() ![]() ![]() Group: Members Posts: 156 Joined: 15-February 08 From: US of A Member No.: 150 |
Hey,
I have never ever done this in my life but I have seen it done many times. I am building a photographer's website and he wants to have several images displayed on his site. The images are public domain and he doesn't care if anyone steals them as they are such low quality images. However, I am going to be hosting about 200 high resolution print quality photos as well on this site and I need them password protected. While I can password protect each directory I need to make it where I can create a user to have access to an individual photo. I've thought about all kinds of things but I can't think of any workable solution. If I make a php page where it "unlocks" a photo for that user can't they then just grab the php page and get the password for the directory... Any ideas, help, suggestions, tutorials would be great. -------------------- Currently Available for work: - XTHML, CSS, Flash, Actionscript, PHP, ASP, Ajax -
interested in movies? Read some of my reviews on my blog |
|
|
Mar 20 2008, 11:45 AM
Post
#2
|
|
![]() Squeeze Machine ![]() ![]() ![]() ![]() ![]() Group: Team Leaders Posts: 569 Joined: 13-February 08 From: Catching the squeezed drips downunder. Member No.: 13 |
You can use PHP's ability to work with binary data and have one PHP script that serves up each image after performing some logic checks to ensure that the user is allowed access.
Let's say that you use a session to validate the user and use your normal checks then you could have a php script that accepts some $_GET query string data with the image name etc.. Then you can use file_get_contents($file) to retrieve the image from the server (this function is binary safe)... after clearing the default headers and then setting headings like "Content-type: image/jpeg" and echo out to the browser. Because of the content-type heading, the browser will treat it like any image linked to directly. If you wanted to avoid storing the images in directories at all, you could also consider storing them in a MySQL database with the data-type set to BLOB... Then using the same content-type headers you can dump the image straight out of the database meaning that it would never be possible to get the image outside of a valid user session. CODE <?php
if ($you_are_allowed) { $img = file_get_contents('path/to/funky/' . $_GET['images']); header('Content-type: image/gif'); echo $img; } else { // do some other stuff like output a default "not allowed" image } ?> -------------------- Bright Idea? -- Don't Let it disappear
|
|
|
Mar 20 2008, 05:02 PM
Post
#3
|
|
![]() Rapid Squeezer ![]() ![]() ![]() ![]() Group: Members Posts: 156 Joined: 15-February 08 From: US of A Member No.: 150 |
Wow.. storing an image in a database seems to be the best possible solution. I never knew it was possible to store an image... I'm going to have to look into that. The fear I have with the using directories is that people could type in the location of the image and download it if they grab the password which could happen if they were to download the php file.
Thanks for the idea man I'm so gonna do that -------------------- Currently Available for work: - XTHML, CSS, Flash, Actionscript, PHP, ASP, Ajax -
interested in movies? Read some of my reviews on my blog |
|
|
If you found The Web Squeeze to be helpful, please donate so we can keep this site FREE, FRESH, and fortified with Web Design & Development info!
![]() ![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
10 | Popje | 284 | 4th April 2008 - 10:07 PM Last post by: Popje |
|||
![]() |
6 | LivingDeadBeat | 181 | 20th March 2008 - 11:15 AM Last post by: JustinStudios |
|||
![]() |
11 | jamesicus | 303 | 12th April 2008 - 01:48 PM Last post by: jamesicus |
|||
![]() |
5 | rewake | 162 | 8th April 2008 - 03:01 PM Last post by: Rakuli |
|||
![]() |
2 | paintingtheweb | 86 | 11th April 2008 - 11:12 AM Last post by: paintingtheweb |
|||







Mar 20 2008, 11:29 AM







