[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

How to insert pictures in database

I have list of cars and i want to stick 3 serperate pictures for each car. Im just wondering how would i go about storing them in database and also how to retrieve them from the database on display them on page

I have three pics called image1, image2, and image3 and i have them stored in folder called c:\opensa\apache\htdocs\HBC\images2
0
acslater
Asked:
acslater
2 Solutions
 
minichickenCommented:
Hi

This is a very popular question:

Have a look at this PAQ

http:Q_21205707.html - MySQL image placeholder

Hope this helps :)
0
 
acslaterAuthor Commented:
Do i store the path to the picture in mysql. for example would iput in c:\opensa\apache\htdocs\HBC\images2\image1 in the database as a value
0
 
minnirokCommented:
Basically if you're storing filenames in your database, the database's usefulness is only in knowing where to find each image file.  You wouldn't want to write an absolute reference to the images like "c:\\opensa\\apache\\htdocs\\" etc...  This will limit your options should you ever have to move your system to a linux machine, or another directory on your windows machine.  Just reference each file relative to the main image directory on your web system...

The trick with these filebased database systems is keeping an orderly filesystem for all your images.  Often it's helpful to name images or image subdirectories after SQL ids for each item (each car's ID, in this case).
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
virmaiorCommented:
storing the path is the far preferred solution.  And systemizing the paths as minnirok suggests is also a helpful detail.

storing images themselves in the DB doesn't really get any DB benefits.   This is because the DB stores them as BINARY BLOBs, not the most friendly data type, since all your storing is really a file.  You don't get any search benefits from this.

0
 
acslaterAuthor Commented:
i have read the previous examples but dont fully understand. So i have just manually put the picture into the database. The name of the field in the database is called people and the image is called image1. I have put in c:\opensa\apache\htdocs\HBC\images2\image1 for each field.

Could anyone show me code just to view this image? its hardly as easy as:
<? echo $row["people"]; ?>.gif

0
 
acslaterAuthor Commented:
yes got them to show tanks lads. how can i split the points because ye all helped out
0
 
cachedVBCommented:
Hi acslater,

Check out the instructions on how to split the points here
http://www.experts-exchange.com/help.jsp#hi19

cachedVB
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now