I have a folder with images and I'd like to have the image names displayed in a table, next to a corresponding customer number (which is pulled from a database) or if no image exists, then a noimage.jpg would disply as default. Can I do this in ColdFusion without having to reference image names from a database, etc.? For now, the images are just sitting in a folder. If so what code would I need to use? Thanks.
Yes, its based on the customer number, ie.
<td width="74%" align="left" valign="top"><img src="../RepInformation/images/#CustomerNumber#.png" onerror="this.src='../RepInformation/images/noImage.gif';"></td>
Probably. I don't need it to just print a list of files. I need it to display each individual image file name to the right of each record. Here is a screenshot of the tabel I have to add it to. Right after Territry, I need a column with 11871.jpg, 11899.jpg, etc and then any record without an image would show "noimage.jpg". Hope this makes sense.
Need to understand whether the database is driving the list, or are the contents of the folder driving the list. If you are looping through a query resultset from the database, that has the customer numbers and territory info, which is what it sounds like, then what you are really asking for (I think) is whether that customer's corresponding image file exists. In which case you want the cf function named, you guessed it - fileExsits().
If on the other hand you are driving this beast from whatever is in the folder, and looking for the corresponding data in the database, then use CFDIRECTORY and parse off the customer number in order to do the SELECT against the table. But I don't think that is the scenario you are describing.
Did either of those putts make it into the cup?
As others have mentioned, cfdirectory will provide you with the file names. You can query your db for other stuff and put it all together with Query of Queries.
Some of the details might be tricky. Good luck and post back if you have difficulty.
Thanks everybody. I got it to work. Here is my code in case someone else needs help:
|<td><cfif FileExists("\\ncc1701-01\web\Sales\Information\images\#CustomerNumber #.png")>|