You are here: Re: Accessing images in a protected directory « PHP « IT news, forums, messages
Re: Accessing images in a protected directory

Posted by "M. Sokolewicz" on 09/13/05 20:19

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация