Skip to main content
Known Participant
December 22, 2008
Question

Database images

  • December 22, 2008
  • 18 replies
  • 2296 views
I am using CF developers edition, sql 2005 and dreamweaver cs4 I have followed many tutorial on hoe to do this but I still get the same problem. I have built a record set from my db to display dynamic images. The images are stored in a folder outside of my database. I have a table with a column that has the path to the image file within the record set for example I have a varchar coulmn and the record is c:/documentandsettings/images/1000.png or something like that. Now when I try and display the image from the record set in dreamweaver I get the location to the image to display but not the actual image. What am I doing wrong? Please help
This topic has been closed for replies.

18 replies

Known Participant
December 31, 2008
Thanks guys this is all so new to me, i still have training wheels on and you guy have motercycles I really do apperciate your patients with me though. I know it can be hard.
Inspiring
December 30, 2008
ibejaminben wrote:
> Mack could you give me an example? If i do that where are they on my local system? how does CF find them? Thanks Mack

Lets straighten something out here. ColdFusion does not find the
images, it does not even look for it.

ColdFusion builds HTML. ColdFusion delivers that HTML to the Web Server
to be delivered to a client's browser. The browser parses the <img...>
tags and asks the web server to deliver those files as well. The web
server then delivers the images from where the <img...> tag told it to
find them.

So the first step is to build a basic HTML page with hard coded <img...>
tags. That tells you that you have your HTML and web server working
together to correctly deliver the web pages and associated images to the
client.

Then you replace the hard coded HTML with dynamic CFML code that builds
the same HTML <img...> tag it is replacing.

Then you can put the data required for the <img...> tag into a database
so that it can be easily stored and edited with other process.

That is the basic path we have been trying to guide you down.

Known Participant
December 30, 2008
Mack could you give me an example? If i do that where are they on my local system? how does CF find them? Thanks Mack
Inspiring
December 30, 2008
Inspiring
December 30, 2008
ibejaminben wrote:
> I know i really shouldn't double post as I know it is bad forum etiquette but i
> didn't want to forget this question. How do i store my images in my database so
> that when I upload my database to my hosting account the paths to the images
> are intact and the images display properly?

Store just the names of the images, not the full disk path and prefix
the file name with the directory in your output code.

--
Mack
Known Participant
December 30, 2008
I know i really shouldn't double post as I know it is bad forum etiquette but i didn't want to forget this question. How do i store my images in my database so that when I upload my database to my hosting account the paths to the images are intact and the images display properly?
Known Participant
December 29, 2008
Wow Dan thanks, but I have no idea what that will do HA HA HA. It might as well be in Greek. What does that code do for me. I can't thank you enough for your support. I somehow though this was going to be much easier boy was I wrong. It didn't look that difficult in the lynda .com DW Dynamic development training, which is where I have been learning I am kind of a visual guy. Some me how to do something and I will be able to do it again and again.
Inspiring
December 28, 2008
Every developer I have met that uses DW uses the code view, not the design mode. I do it myself, and all I really use DW functionality for is autocompletion of tag and attribute names, and autoselection of attributes. But, then again, I was already a programmer when I started using CF.

My suggestion is to start taking control of your code instead of relying on DW to do it for you. I also suggest taking baby steps, something I still do. You can start with your image tag. Let's say your image resides here:
c:\webrootdirectory\dir1\file123.jpg

Start by hard coding an img tag
<img src="/dir1/file123.jpg">

Once that works, use a variable.
<cfset thefile = "/dir1/file123.jpg">
<cfoutput>
<img src="#thefile#">
</cfoutput>

Once that works, use the replace function to convert this:
c:\webrootdirectory\dir1\file123.jpg
to this
/dir1/file123.jpg

If you don't know how the replace function works, google "coldfusion replace x" where x is the version of CF you are running.
Known Participant
December 28, 2008
Yes Dan I am using DW in design mode I just didn't know where else to turn I have been searching everywhere for an answer. Maybe you could point me in the right direction. I know it is possible because I have seen it done in the tutorials I tried to follow but their circumstances were different. How do other people build shopping carts using databases with hundreds of products using CF and DW? Any advice would be greatly appreciated.
Inspiring
December 27, 2008
Chances are you got the img tag wrong. What does it look like? How does it compare to Ian Skinner's first answer?

As an aside, are you using DW in design mode? If so, you are on a different wavelength than anyone trying to help you because we all deal with source code, at least I do.
Known Participant
December 27, 2008
What is the easiest way to do this? I have tried to use and image tag as you suggested Dan so thank you and sorry for not mentioning it earlier. It was an <img src> tag You guys are in the know. I just want to create a recod set from my database. My database holds a table that has two coulums in It with paths to my actual images. The thumbnail and the large image. The table also holds other information I need in my record set such as size color and so on. Using Dreamweaver I want to build a shopping cart to display this information in a master detail page so that it repeats once for each record in my record set. I also have to upload my site and database to a server when I go live as I will be having someone else host my site, Right now I am just testing as I build using dreamweaver and CF developers edition. Again thank you for taking the time to help. This is all very new to me but I enjoy learning
Ian, Dan, Azadi, or anyone else how would you do this? Maybe that's what I should have started asking first. Is there a better way I am still building and developing so nothing is set in stone.