This content has been marked as final. Show 3 replies
Are the documents stored on the server, or stored as binary data in the database? what seems to be the problem? The code looks ok. I'm assuming you are storing the full path to the document in the variable URL, in which case clicking on the link should bring up your document assuming that the file exists on the server.
Here is a simple illustration with the extension hard-coded.
<cfquery name="getEmps" datasource="cfdocexamples">
SELECT firstname FROM EMPLOYEE
You say " Most of these are pdf."
You will need to leverage ColdFusion's file and string manipulation functions to identify the document extenstion and pass them to the url accordingly
See http://livedocs.adobe.com/coldfusion/7/htmldocs/00000353.htm for help with ColdFusion functions
From Rockhiker's first post, it looks like the filename is stored in the database without a file extension. Just to clarify, do you have the full filename (with file extension) stored in your database? If not, there are solutions, but I would definitely recommend adding a field for file type to your application.
If you don't have the file extension of the file, but know it is one of only a handful of file types, you can use the fileExists() method to determine the correct filetype:
<cfset sFullFileName = "#myFile#.pdf">
<cfset sFullFileName = "#myFile#.doc">
Otherwise, you could leverage <cfdirectory> to get a list of all your files in a query format and then compare your filename against the values in the directory.