467,915 Members | 1,536 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,915 developers. It's quick & easy.

Displaying photos in PHP

Hi,

We are building an internet based application that would allow any one
to purchase online (php generated) reports that include a few
photographs.

What is the best way to serve the images so that the user wouldn't get
hold of other images on the webserver?

Thanks in advance,
R Padala

Nov 22 '05 #1
  • viewed: 1259
Share:
1 Reply
*** R Padala escribió/wrote (18 Nov 2005 07:23:48 -0800):
What is the best way to serve the images so that the user wouldn't get
hold of other images on the webserver?


Keep them in a folder out of the public folder tree and write a download
script to serve them.

If your web is under /home/foo/htdocs you can create /home/foo/pictures and
then write a script that:

1) Check credentials
2) Find picture's file name
3) Send appropriate "Content-Type" header
4) Read file and output it to browser

Some helpful functions:

mime_content_type()
getimagesize()
header()
readfile()
--
-+ Álvaro G. Vicario - Burgos, Spain
++ http://bits.demogracia.com es mi sitio para programadores web
+- http://www.demogracia.com es mi web de humor libre de cloro
--
Nov 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Ross | last post: by
1 post views Thread by David Lozzi | last post: by
4 posts views Thread by Dave G | last post: by
4 posts views Thread by cheryl | last post: by
1 post views Thread by David C | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.