functions/includes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dlibby
Forum Newbie
Posts: 3
Joined: Fri May 02, 2003 12:35 pm

functions/includes

Post by dlibby »

I am fairly new to PHP. And I have searched high and low for information on this problem and since I haven't had any luck anywhere else and don't seem to have anyplace else to turn at the moment I thought I would give this a try. I believe it is probably a simple problem but....

So that being said:

I have a website. I have put a membership search on this website. You search by First and/or Last name. (No problem there). If there is a match in the mssql database you get the results displaying 5 at a time, showing their User Id#, First Name, and Last Name. The User Id# is hyperlinked so if you click on it it will bring you to a detail page that contains more information about this particular member. (No problem here either).

My problem kicks in when I am trying to link the User ID# to an image of them in a folder located on the same Drive as the website but not in the Web itself. Does anyone know how I would go about searching a folder with images in it that are named the same as the User ID#'s, and displaying the corresponding photo along with all the other information I have pulled up from the database?? I have tried several things and so far nothing has worked. I have been to several hundred places looking for answers, and so far no luck. Any help with this would be more than greatly appreciated. Thanks in advance. :?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Could we see the code you're currently using?

Mac
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post by hedge »

If I understand you correctly you need to display an image that is not in the web root. If so you can do it like this:

Code: Select all

-- html
<html><img src="getpic.php"></html>

-- getpic.php
<?php
 header("Content-Type: image/jpeg");
 file(<path to file>);
?>
?>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

readfile() instead of file()
Post Reply