store and display images in a db

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
meHere
Forum Newbie
Posts: 2
Joined: Mon Oct 18, 2004 3:24 pm

store and display images in a db

Post by meHere »

How do I store pictures in a db and then display the pictures on my site? for each item stored in my db i want to display a picture of it. i upload the location in memory of the picture using a form and store it but after that i am lost. how do I use this location to display the image. I have read books, other posts and various sites but still i can't get it to work.

Any ideas at all will be very much appreciated
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you store the url of sorts to get to the image. Not necessarily a full url, as that will waste space with redundancy.. so in your image retrieval function, you just tack on the information needed to create a qualified url the browser can use to access the image.

Alternately, you can create a script that sends the image to the browser. you can find out how these are done by using the following forum search: [devnet]+force +download[/devnet]
meHere
Forum Newbie
Posts: 2
Joined: Mon Oct 18, 2004 3:24 pm

Post by meHere »

when i am adding a new product to the db i also add an image such as pic.gif typed in by the user. Then to display this i use

Code: Select all

<?php echo '<td width="7%" align="center"><img src="'.$file.'" alt="my picture"/></td></tr>';

?>
where $file is equal to what the user typed in i.e pic.gif but all that is displayed is a white box with a red x in it. Do you know what I am doing wrong?? Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

post more of the code.
Post Reply