Re: Accessing images in a protected directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Brian wrote:
I haven't used .htaccess before and am currently having an issue with it.

I have a site that has photos from various events on it. Some of the events need to be password protected to view the photos. They enter a password, it gets checked in the MYSQL database and then the php page tries to pull the protected photos from the directory that has .htaccess on it. Yet, everytime it tries to pull an image a username and password dialog comes up.

How do I pass this information automatically when I try to get the images so the dialog doesn't come up? Or am I approaching this wrong?

Thanks in advance for the help...

Unfortunately, you can't pass along a username/password to apache in a simple way. However, a different approach would be to create a script in the same directory as your main script is in. And then call all images via that script (eg. image.php?img=abc123.png). Then in that script that recieves all requests for the images, basically file_get_contents() (or whatever) the actual image file from the protected directory, set the right headers (content-type mainly), and echo/print out the image.

Another way would be to limit the .htaccess allow to allow only images without getting the user/pass dialog. I'm sure it's possible, but I can't really recall how that is done. It will probably be explained in the Apache Documentation :)

- tul

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux